I have a question


#1

Hello! I am new to python and I have a sort of simple question. You might find out why you do this in later lessons, but because I’m new I am not very far yet. If it is not too hard to understand, I would like to know now. My question is this: If I have the variable
-pizza = "Cheesy and Delicious"
and I do
-len(pizza)
I believe I will get the number of characters in the phrase “Cheesy and Delicious”. If I do
-pizza.lower()
I will get “cheesy and delicious” (in not capital letters because that is what lower() does). Now this is my question. Why do I put the variable pizza in the parenthesis of len() but put pizza before lower() with a period. As I stated above if it is complicated or if I learn it in later lessons, you don’t have to answer. Why do I do
-pizza.lower()
instead of doing
-lower(pizza)
If you don’t understand what I’m asking you can tell me and I will try to make it more clear. But if you do and you want to answer that would be cool.
if someone who works at codecademy says this I am really enjoying your courses so far and I thank you for making them. I hope to get a job that includes programming one day!

Bye!! and thanks for answering if someone does :slight_smile:


#2

.lower() is a method of the str class, and only works on string objects.

len() is a standard function that returns the length of any iterable, strings included.

This will come up in much greater detail later, so don’t get hung up on it. When you get to data types and data structures it will begin to unfold. Then when you reach the unit on classes, it will be fairly self-evident.

Be sure to locate the python docs at docs.python.org so you can do follow up reading on each new topic.


#3

Ohhh I understand. I feel kinda stupid for not knowing that xD Thanks for answering!


#4

You’re welcome.

Never say stupid, since only a stupid person would pass up on this question. You asked, that makes you astute, not the latter.