Access by index


#1

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

what did i do wrong?


#2

You didn't access the letter through an index, you simply assigned "Y" to a variable. Perhaps this would help:

nth_netter = "STRING"[n]

print nth_letter

#3

Thank you for the assistance


#4

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