In using string methods


#1

len()
lower()
upper()
str()
Why is the syntax different for each one?
example:
parrot = "Norwegian Blue"
print len(parrot)
and
parrot = "Norwegian Blue"
print “parrot”.lower()
^ and not print lower(parrot) like the upper len string method?
Can anyone explain?

Strings and Console Output


#2

because len() is built-in function, .lower() is a method belonging to the string class.

its confusing at first, but once you learn about function and classes, it will make more sense.

warning, this might be overwhelming, but here is what you want to know:

https://stackoverflow.com/questions/11801549/python-data-types-are-classes-or-data-structures


#4

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