Access by Index not working


#1



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


When I enter Y to define the variable named " fifth_letter " as it says to do in the hint I get the message:
"Oops, try again. Remember to use the string "MONTY" (all caps!) in your code."
What does this mean.

I get to pass the level


"""
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

When they tell you to access it by index they mean for you to do it in this format as shown in the instructions:

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

I'm sure you can figure out your mistake now. :slight_smile:


#3

Thank you. I got passed it>


#4

Welcome! Glad to help! :slight_smile:


#5

I'm still trying to work out this code. I have tried done numerous attempts to resolve this operation, however I've been unsuccessful. I came across your post and I still do not understand where the issue is occurring.


#6

Can I see your code?


#7

So complicated, yet so simple. I feel like a complete idiot!!!:flushed:


#8

@mystfan Don't, I was confused myself when I first learned it. :smile:


#9

I am stuck on this and have been for several weeks. Please can somebody help me?


#10

Can I see your code?


#11

I am stuck and have been for a couple of days. Could someone help me.


#12

I would be happy to help you, but it would be best if you created a new thread.


#13

This worked for me.

"""
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 = "MONTY"[4]
print fifth_letter


#14

It's very complicated, but the answer is

"MONTY"[4]
0 1 2 3 4
we have 5 letters and he asks the fifth letter in (MONTY)
and remember in programming we begin with 0


#15

I feel so stupid. It reminds you to start counting from "0" and my brain automatically says "NO! start at 1." Stupid over thinking.


#16

fifth_letter = ""MONTY"[4]


#17

It takes time to sink in, don't hate yourself for it. :slight_smile:


#18

Arrays always throw me :confounded:


#19

For some reason the code below is not working despite me following your instructions, please can you help.

"PYTHON"[1]
fifth_letter = "MONTY"[4]

print fifth_letter


#20

Do you have any indents? Also, if this line:

Isn't a comment, then it may be part of the problem. Not sure about that though.