Why do we write this method after the variable, unlike len( )?

Question

Why do we write this method after the variable, unlike len( )?

Answer

Some methods, like len( ), are built into Python and can be used on lots of different things. Others, like lower( ), belong to strings, and can only be used attached to strings, and that’s why you see them attached at the end of a string instead of being on their own with a string inside their parentheses. A lesson on this exact topic, with more detail, is coming up soon!

27 Likes

I had noticed this earlier and got confused – did the wrong thing here…think it would be helpful to explain this earlier – hate having to get things wrong especially as you example on a previous screen showed lower followed by parens… Another thing which is confusing is why you have to put empty parens round things like this example print var.lower()
Not your fault - nature of the language but it needs stressing earlier.

25 Likes

That is the challenge, to explain these concepts earlier on, you would overload learners with information like functions, methods, classes, instances and so on. Not a great idea either

13 Likes

I completely agree. I feel like I was tricked into getting it wrong which is a really demotivating way to learn something new.

It’s not as if the information is really that complicated at this point. No need to hold back on the explanation until two cards later.

9 Likes

My issue is how the instructions are worded. it actually doesn’t make sense when you read it. I could infer what was intended based off the example ( kind of) butttt…you guys gotta work on being more explicit in the instructions. it literally made no sense, what does “call lower()” mean? should it say “enter” or “type lower()”?

9 Likes

That make so much sense, thanks a lot!

IMHO this is exactly the right way to learn. To spoon feed us explicit instructions means that we plod on without having to think - making errors in a safe environment demonstrates what can go wrong and we remember that.

16 Likes

Is actually a perfect way of teaching. it makes you use your head, doing your researches (with The Google machine :smiley: ) and so on. otherwise it would be too easy and wouldn’t benefit you. Also before starting a programming language i would start reading some computer science book or watch some video, it really opens your eyes and programming will make more sense :wink:

I have to disagree, I find the best way to learn is to fail.

1 Like