What is wrong in this code?


#1

On line 13, assign the variable fifth_letter equal to the fifth letter of the string "MONTY".

Remember that the fifth letter is not at index 5. Start counting your indices from zero.

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

print fifth_letter


#2

They gave you an example of how to get the "Y" in "PYTHON". Which is "PYTHON"[1] as you can see that indices start at 0.

So....you do something similar to get the "Y" in "MONTY". As in

fifth_letter = "MONTY"[n] #replace n with the index that Y is in

#3

That is because it tells you that the answer is Y


#4

DIdnt still work. Used fifth_letter = "MONTY"[4}


#5

Start counting indices from zero. The Y is at the index 4.

print fifth_letter[index]

Replace index with the number at which you've Y :slight_smile:


#6

Hi, replace the closing } with ]


#7

This is a bug I'm sure Y is the 4th number when zero is included
Im guessing whoever wrote this programs in another language and forgot the python logic


#9

I was stuck with this one too! Wasn't paying attention to the fact that your result is supposed to say "Y".

M O N T Y
0 1 2 3 4
fifth_letter = "MONTY"[4]

Thank you, guys! :slight_smile:


#10

Issue has been resolved. Thank you for all the feedback


#11

It keeps telling me that the fifth letter is not "MONTY"[5] even thought I have it set to "MONTY"[4] What am I doing wrong?


#12

Did you store it in the variable they gave you called fifth_letter?


#13

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