Why are len() and str() called differently than upper/lower()?


#1

print str(pi)
print len(pi)
print cityname.lower()
print state.upper()

Why is this notation different for calling on methods for variables? This confused me going through the tutorial. Why couldn't I use "print lower(cityname)"?


#2

Hello @designrockstar87064, it's because len() and str() are not really string methods but more like python built-in functions while lower() and upper() are string methods, if you give a look to the python 2 docs you won't be able to find in the built-in functions upper() and lower() as they are methods.

Give a look to this:

https://docs.python.org/2.7/library/functions.html

I hope it was clear enough, if you need anything else let me know!