"MONTY" (all caps!)


#1

Very confused with the PYTHON string. It's telling me "On line 13, assign the variable fifth_letter equal to the fifth letter of the string "MONTY". So what's the fifth letter? If M is considered 0, and there's only 4 other letters, then I'm lost. This is probably basic but I'm pretty dumb/new to this so...yeah. But I even attempted to do "MONTY" because it told me that was the value of the fifth letter but then it said, "Oops, try again. The value of fifth_letter is "MONTY" instead of "Y"." I was doing "MONTY" as the value, not "Y".


#2

@colapepsi007,

MONTY

M   1st Letter, "MONTY"[0] 
O   2nd Letter, "MONTY"[1] 
N   3th Letter, "MONTY"[2] 
T   4th Letter, "MONTY"[3] 
Y   5th Letter, "MONTY"[4]

print "Monty"[0:4]  ==> MONT
print "Monty"[1:2]  ==> O
print "Monty"[1:3]  ==> ON
print "Monty"[0:]   ==> MONTY
print "Monty"[:4]   ==> MONT


MONTY string solution does not work and stuck at this lesson
Acces by index
Pytons
#3

Hey @colapepsi007
Don't confuse "index" with letters.
Zero-based numbering is a design choice in many programming languages.
Under zero-based numbering, the 1'st element has a index of 0, the 2'nd element as a index of 1 ... N'th element has a index of (N-1)
"MONTY" obviously has 5 letters.
Its 1st element i.e "M" will have a index of 0.
Its 2nd element i.e O will have a index of 1.
And so on..
Hope this provides some clarity


#5

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


#6

@desirefon,
Please provide the code you are using....
and the instructions you are following....


#7

Hi Leonhard
i still have the same problem what should i do" Oops, try again. The value of fifth_letter is "MONTY" instead of "Y"."


#8

@dswai,
Please provide the code you are using....
and the instructions you are following....


#9

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

print fifth_letter


#10

That was unduly harsh. Not Very intuitive the way that it's assembled, but maybe that's because I'm a noob


#11

The string "PYTHON" has six characters,
numbered 0 to 5, as shown below:

 1st 2nd 3th 4th 5th 6th  letter
+---+---+---+---+---+---+
| P | Y | T | H | O | N |
+---+---+---+---+---+---+
  0   1   2   3   4   5   element

So if you wanted "Y", you could just type
"PYTHON"[1] (always start counting from 0!)

fifth_letter =

print fifth_letter


#12

I had the same problem and I came here to look for the solution, the answer of leonhard_werrengmx_n helped although I still don't understand completely but I typed "MONTY"[4] , since as leonhard_werrengmx_n explained the fifth letter is counted [4] if we start counting from [0]


#13

i think that Y are 0 condition...i work them and something ist not right...i have 3 days...


#14

Thanks, this resolved it


#15

fifth_letter = "MONTY"[4]
This worked for me it was pretty easy when i noticed how they did it with "PYTHON"


#16

Agree with you, abraham 3434!


#17

The same happened to me...
So "MONTY"[4] is the answer, but I don't understand why


#18

Python starts counting from 0 not 1

Therefor to print the 5th letter or Y

python reads it as

"M" = 0
"O" = 1
"N" = 2
"T" = 3
"Y" = 4

Thats why it uses [4] because it equates to Y

Also if you scroll up, leo has a couple more detailed diagrams that explain better than mine. :slightly_smiling:


#19

answer is fifth_letter= "MONTY"[4]
because M is the first_letter but you say it a [0] so Y is the FIFTH_LETTER but you say it as [4]


#20

Without reading this thread I would never have got to the right answer so I'd suggest when this lesson gets re-written a little more explanation would be good


#21

Thank you sooooooooo much