Len() v.s. " .upper() & .lower() "


I felt that len() works like a function, therefore when we input a variable into the parenthesis the function would start to operate.
But why not .upper() and .lower() work in the same way? I mean in the same syntax as len()?

For example,
print len(parrot)
print parrot.lower()
print parrot.upper()

why not
print lower(parrot)
print upper(parrot)

Please leave the following link in the post so we can find the unit module, else replace it with a link to the exact lesson:

Strings and Console Output


I’ve just found the anwser:

Methods that use dot notation only work with strings.

On the other hand, len() and str() can work on other data types


methods are specific to a datatype, but different data types can have the same method implemented.

and functions don’t have to work on all data types, its just possible they work for multiply data types


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