Access by index, no idea what i am doing wrong


#1

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

I tried on line 13 "MONTY" and "Y" and both didn't work

I'm not sure what I am doing wrong, I am new to Python


#2

I am new to python as well and was having trouble with this too. However, you are suppose to assign the variable equal to "MONTY", which is all caps and beside that insert [4] because "Y" is number four from 0-4, which is the fifth letter.


#3

I'm stuck too. And I have no idea at all of what I am doing wrong.


#4

Well Python counts the letter starting from 0.

+---+---+---+---+---+
| M | O | N | T | Y |
+---+---+---+---+---+
 0    1   2   3   4

the lesson wants you to print the 5th letter of MONTY which is Y, though in Python it would be the 4th letter.

you have to create a variable "fifth_letter" and set it equal to the 5th letter of MONTY using "MONTY"[4]
then you print "fifth_letter"


#5

Thanks- I was so stuck on that one and now I'm free to move on. Sigh


#6

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