Possible Typo in Excercise?


#1

In the instructions, it says,

On line 4, use .len() to print the length of my_string.

This is insinuating to do something like

print my_string.len()

rather than it says to use len() to print the length of my_string, making users do

print len(my_string)

This was simply a problem that I had encountered and finally figured out how to do it. I feel that these instructions might be a bit misleading, unless that is the proper way it should be. Just thought I should point this out.

Strings and Console Output


#2

Seems to do no such thing. How would a learner who knows nothing of methods be led to this conclusion?

print my_string.len()

The lesson shows,

print len(my_string)

Seems very likely they will follow that pattern and not read anything else into it.


#3

In the actual directions it says to use .len() when you should be nesting (is that the right word?) like len() text

I’m just saying that the period seems to imply that it should be at the end of the variable, rather than the variable to be nested inside of len()

Again, I could be wrong.


#4

I’m still mystified by which lesson this is.

On line 1, create a variable named parrot and set it to the string "Norwegian Blue".

On line 2, type len(parrot) after the word print, like so: print len(parrot). The output will be the number of characters in "Norwegian Blue"!


#5

This is in the lesson of Strings, exercise 16, titled “And Now, For Something Completely Familiar”

All I am trying to say is that the instructions specify to use .len() instead of using len(), and I think this may be incorrect

I think I should have specified the exercise, I hope I said this more clearly now.


#6

That still means we have to search for the correct lesson which is a pain. A link is what was asked for. Please and thanks.


#7

https://www.codecademy.com/courses/learn-python/lessons/strings--console-output/exercises/and-now-for-something-completely-familiar?action=lesson_resume

(I thought it was linked in the OP, my bad)


#8

That link goes to the start of the unit, but not the lesson. Guess I could have chased down the lesson from there (also, my bad, so we’re even).

Hopefully you will make a habit of starting a new topic with a link from now on. You get much quicker and more accurate responses that way.

Now I see what you mean…

Let’s wrap it all up!

On line 3, create the variable my_string and set it to any string you’d like.
On line 4, use .len() to print the length of my_string.
On line 5, print the .upper() case version of my_string.

Clearly you raise a valid point. Be sure to write a bug report on the instruction text so this error gets corrected. Sorry for the run around.


#10

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