Help


#1

On Python's lesson 4, I have no idea how to do Access by Index.
"""
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 = "Y"

print fifth_letter

Instructions : 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.


#2

Hi your code should be like that

fifth_Letter  = "MONTHY"[4]
    print fifth_letter

#3

Okay so look at it like this:

Say you have a list of numbers:

numList = [1, 2, 3, 4, 5]

each one of those numbers have a place in the index, but you don't count like you would normally. This is how the computer reads that list:

[0, 1, 2, 3, 4]

So this is how you have to reference them!

[1,2,3,4,5] (numbers)
-v-v-v-v-v-
[0,1,2,3,4] (indicies)


Now to deal with this lesson:

It tells you to assign the variable fifth_letter equal to (=) the fifth letter of the string "MONT(Y)". And to remember that the fifth letter is not at index 5! Start counting your indices from zero. So,
M --> 0
O --> 1
N --> 2
T --> 3
Y --> 4

So we are going to do this:

fifth_letter = "MONTY"[4]
print fifth_letter

Because the fifth letter is actually at index 4.

I hope this helps :slightly_smiling: