HElp me with this example


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[4]

i write it in the right way but still give me error massage please help me


What error is it giving you?


Oops, try again. The value of fifth_letter is "MONTY" instead of "Y".


i don,t know what to do


The way your code is written you are assigning fifth_letter the value of "MONTY" meaning that when you print fifth_letter it will output "MONTY". What the exercise is asking for is that you set fifth_letter equal to the fifth letter of "MONTY". So if you were to print fifth_letter it would output "Y".


i don,t know what you mean


can you explan more to me


Sure. So if we go back to the example with PYTHON. If I have
second_letter = "PYTHON"[1]
print second_letter

It will print out "Y" because second_letter is set to equal not "PYTHON", but instead the second letter, "Y".

Currently, you have fifth_letter equal to "MONTY" so if I ran print fifth_letter it wouldn't output Y, it would output "MONTY".

Now you are running print fifth_letter[4] which makes the output "Y", but the value of fifth_letter is still equal to "MONTY" when it should be equal to the fifth letter of "MONTY" which is "Y".


thanks i solve the problem


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