Can someone explain this


#1

Please leave the following link in the post so we can find the unit module, else replace it with a link to the exact lesson:

Strings and Console Output

https://www.codecademy.com/courses/learn-python/lessons/strings--console-output/exercises/access-by-index?action=lesson_resume

Can someone explain this because i don’t understand it and i believe i am getting a different answer from the hint and the code the was given to me. Even after i got the code from the lesson i am still getting a error code here is the error code [ Your code looks a bit off. Check the Hint if you need help! Your code threw the following error: name ‘Y’ is not defined]. And this is the code that was given to me [fifth_letter = “MONTY”[4]


#2
"""
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!)
"""

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.

fifth_letter = "MONTY"[4]

print fifth_letter

#3

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