String and console


#1


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

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"


#2

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

#3

@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:

"RAPUNZEL"[3]

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

Good luck and happy coding! :slight_smile:

-- @chipjumper36731


#4

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


#5

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