My understanding of the print() in both Python and Ruby (and other languages) is that it is a method on a string (or other types). Because it is so commonly used the syntax:
print “hi”
works.
So why doesn’t "hi".print() in Python or "hi".print in Ruby work?
When you do something like
"hi".print(), you are implying that the string object"hi"has a methodprint. This is not the case. Instead,printis a function that takes a string (or other types) as input.