Help on lesson 4, strings & console output, python


his is the error message it came up with:
"Traceback (most recent call last):
File "python", line 13, in
NameError: name 'Y' is not defined"

I expected it to say "way to go [start next lesson]" or something like that.

The string "PYTHON" has six characters,
numbered 0 to 5, as shown below:

| P | Y | T | H | O | N |
  0   1   2   3   4   5

So if you wanted "Y", you could just type
"PYTHON"[1] (always start counting from 0!)
fifth_letter = [Y]

print fifth_letter


What you really want is a string Value "Y"
to be assigned to the variable fifth_letter
fifth_letter = "O"

You could also use a so-called slice method
fifth_letter = "Python"[4]


I am confused on this problem. Ive tried fith_letter= "PYTHON" [4] and "MONTY" [5]. can I get some clarification and explanation please :). I'd love to master python and more to be an analyst. HTML&CSS are a piece of cake compared to this haha.




thank you! marccohen. can you explain why 4? thats the only thing I'm not understanding


In this code you start counting at 0 not 1 so the Y in Monty is 4 not 5


Thankyou so so much:smiley:! I've been stuck on this exercise for ages!


thank you leo well i am the one who was asking for the rock paper scissors on javascript


Line 13 should read:

fifth_letter = "MONTY"[4]

This returns the result Y


I still don't get it. I typed in fifth_letter = "MONTY"[4] but it won't work


Make sure you didn't make a typo anywhere else. I was so frustrated for about an hour or so only to realize I put a "1" somewhere by mistake on line 1


marccohen is actually correct I passed this lesson