Fifth_letter = "Y"[5] What's wrong with this code?


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>


Replace this line with your code.


#3

Its Worked i know it was silly but ..... its mine first time to python .....


#4

PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!

please do so, it is for a reason we put it there, it is the best way for us to help you :slight_smile:


#5

Replace this line with your code.

My code is:
fifth_letter = Y

I was wondering what is wrong with this as if i look at the hint it says "The letter you want is "Y"." which is what i have done.


#6

you need to use "string"[x], x being index of the letter you want to retrieve of the string


#7

I have tried this and it is not working.

I have, below, a screenshot of my code.


#8

strings are zero indexed based, counting start at zero, so the 5th letter is at which index?


#9

Assign "MONTY" and fifth letter of the string MONTY


#10

Nothing I think. But remember I think you have to start counting from 0 so
y is 4 not 5 I think


#11

Strings start at 0.

So, it would be=

(Letter on left, Number on Right)
M | 0
O | 1
N | 2
T | 3
Y | ...?

I hope this helps you. Now all you need to is predict/count what the next one is. Just remember, it always starts at 0.


#14

To clarify:

:heavy_check_mark:

:heavy_check_mark:

:heavy_check_mark:

↓↓↓



Strings are zero indexed - The first character is index 0.
So to get the fifth letter, you would use:

fifth_letter = "MONTY"[4]; //because [4] means the 4th character EXCLUDING the one at [0].

Remember, it's the fifth letter that the exercise is looking for, not the one at index [5] (which is actually non-existent).


#15

u must start from 0
M O N T Y
0 1 2 3 4

so.. Y is actually 4 not 5.. the ans=
fifth_letter = "MONTY"[4]


#16