Access by Index isn't working


i think my code is correct but everytime i try it this message pops up: Oops, try again. Your code looks a bit off. Check the Hint if you need help! Your code threw the following error: invalid syntax (python, line 16)

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]      #<--- this is my code

print fifth_letter = "MONTY"[5]

does anybody know whats happening?



fifth_letter = MONTY[4]      #<--- this is my code

monty is currently a undefined variable, why is it not a string?

then here:

print fifth_letter = "MONTY"[5]

you can't print and assign a value to a variable at the same line, print the value of the fifth_letter variable like it was when you started the lesson


im still not too sure what to do, do you know what the answer is?


Yes, i know the answer. But asking and providing answers is against the guidelines, you will learn very little from just copy pasting the answer

See if you can get further with the help i provided, and if you still get stuck, post an updated version of your code + tell what you don't understand


fifth_letter =

you should get the 5th letter of string MONTY (using index), and then print the fifth_letter:

print fifth_letter

this code was provided already by the exercise, you don't have to modify it

so, there is only a single line you need to put some code


thanks for the help, i figured it out and im not stuck anymore :slight_smile: