Inside or outside the parenthesis?


#1

I’m finding it difficult to understand why some functions need the variable inside the parenthesis and some don’t; and more importantly wehn do I know that is one way or te other. The easiest example for this is in the case of lower() and str().

While in lower yo need to write the function like this for it to work:

Somethingsomething.lower()

When using string you have to do it like this:

str(Somethingsomething)

Thanks in advance!

Strings and Console Output


#2

The only object we can manipulate text case on is a string. So it would make sense to give that class of object a .lower() method. Hence, we can only invoke the method on a str object.

str() on the other hand is not bound to a class of objects, but rather takes any class as an argument then represents it as best it can as a string.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.