Using lower()


According to me, the code should work when a string is declared by parrot="HELLO"
print lower(parrot)

I think it should output the string in lower case. But it works when syntax is: parrot.lower()



Hi there, the reason why lower works like this is because the .lower() function will only work with a string. This is called "dot notation", any function that is called in this way will only work using a string:

x = "parrot"
print x.lower()
print x.upper()

The other functions in this section, len() and str(), can be used on other data types, such as integers. Hope this helps you :slight_smile:


Misleading. All classes have methods, not just strings. Dot notation is used to call a class method on an instance of that class. The instance then becomes the execution context for the method.

  |        \
context   method


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