Help on lesson 4, strings & console output, python


#1



https://www.codecademy.com/en/courses/python-beginner-sRXwR/0/4?curriculum_id=4f89dab3d788890003000096#

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


#2

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

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


#3

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.


#4

fifth_letter="MONTY"[4]


#5

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


#6

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


#7

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


#8

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


#9

Line 13 should read:

fifth_letter = "MONTY"[4]

This returns the result Y


#10

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


#11

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


#12

marccohen is actually correct I passed this lesson


#13