Strings & Console Outputs


#1


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

On line 13, assign the variable fifth_letter equal to the fifth letter of the string "MONTY".
Remember that the fifth letter is not at index 5. Start counting your indices from zero.
fifth_letter= I dont understand monty doesn't have a fifth letter and in the hint this is what it says
Hint:
The letter you want is "Y".


I want to find the fifth letter of monty but i do not know how

Replace this line with your code. 
fifth_letter = ?????
print fifth_letter


#2

The instructions to the left show you exactly how to access a specific item.

n = var[0]


#3

This may seem a bit confusing. Normally, we would count a word, for example, "Hungry" as follows: H = 1, U = 2, N = 3, G = 4, R = 5, Y =6. However, within Python's language, it would be counted as follows: H = 0, U = 1, N = 2, G = 3, R = 4, Y = 5.

So if I wanted to find the 3rd letter for "Hungry" (which would normally be "n"), then it would be = 2. In other words:

third_letter = "Hungry"[2]


#4

Ok, so you had to print the fifth letter of MONTY in this exercise, use the [ ] command for that.

fifth_letter = "MONTY"[4]

Remember in python, counting starts from 0.


#5

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