Ok This is the second one I don't understand


#1



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


It says MONTY none in white so I assume that means it is correct


python

"""
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"

print fifth_letter

`


#2

You need an index number after "Monty" and put it inside []. The index number is always one less than the place in the string (because we count the first letter as zero, not one).

The none means the code did not return anything. It simply printed.


#3

Wait, I still don't understand what I did wrong


#4

No, if you see MONTY in the console, it is not correct. They want just the Y in MONTY and not the whole word. Look at the PYTHON example they gave you. They got the Y in PYTHON by doing "PYTHON"[1]. It is because the Y in PYTHON is at index 1 as shown in the neat little chart.

As you can see, indexes start at 0 because that's how a computer starts counting. Y is the fifth letter in MONTY but to the computer, it is the fourth (since it starts counting at 0 rather than 1). You need to do something like the PYTHON example to get the Y in MONTY.


#5

Hey, so what u are doing wring is that u have to print the fifth letter rather u are printing the whole word. You can use the [ ] to print out a letter from the word.
The code will be,

fifth letter = "MONTY"[4]

Remember, in python, js etc counting starts from 0.


#6

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