String and console


It does not accept my capital Y

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"


Please what do you mean by it doesn't accept your capital "Y"?

To print "Y"' or any letter, you should use the index (position) of that letter.

Like this to print the "Y" in the word MONTY.

fifth_letter = "MONTY"[4]

print fifth_letter


@jamescoderchamp When they are asking you to display the fifth letter in "MONTY" they mean for you to do it via the index, for example if I was told to display the "U" of "RAPUNZEL" then I would do it like this:


Do you understand how to do it now? Let me know if you need more help.

Good luck and happy coding! :slight_smile:

-- @chipjumper36731


The first letter is defined as 0 so you would start counting from 1 at the second letter. :slight_smile:


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