0

I'm new to Python and I have a question about the string operations. Is there an over-arching reason that I should understand as to why the lower operation is written as 'variable.lower()' while another one, say length, would be written as 'len(variable)'?

L.Mazzini
  • 3
  • 1
  • `.lower` converts the string to lowercase... when you want a string in lowercase, I recommend using `.lower`. When you want the length, I recommend `len`. – erip Sep 05 '15 at 22:55

1 Answers1

0

lower is a string method, that is, a function built in to the string object itself. It only applies to string objects.

len is a built in function, that is, a function available in the top namespace. It can be called on many different objects (strings, lists, dicts) and isn't unique to strings.

Tay
  • 298
  • 2
  • 8