Hi, I just started Python. I'm new, but learning. I'm stuck, Help?


#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!)
"""

I Kept trying this code:
second_letter="M"[0]
third_letter="O"[1]
fourth_letter="N"[2]
fifth_letter="Y"[3]

print second_letter
print third_letter
print fourth_letter
print fifth_letter

But got this:
Traceback (most recent call last):
File "python", line 14, in
IndexError: string index out of range

and this:
ops, try again. Remember, the fifth letter is not "MONTY"[5]! Remember to start counting from 0. Your code threw the following IndexError: string index out of range

What does it mean by "the fifth letter is not "MONTY"[5]!" ?

so I then tried this:
second_letter="M"
third_letter="O"
fourth_letter="N"
fifth_letter="Y"

print fifth_letter
print fourth_letter
print third_letter
print second_letter

(I know, it displays it reversed, but just to show.)

It shows me the error:
Remember to use the string "MONTY" (all caps!) in your code

What does this mean? Even though I USED all caps in my code. Help? :frowning:


#2

I may be missing something but you never seemed to use the T in Monty and that might be throwing off your fifth letter.


#3

I didn't see that. Looks like I didn't pay attention
Anyway, thanks!


#4

Haha no problem! I make mistakes like that all the time :smiley: Happy coding! And @factoradic does a great job explaining all the errors if you are still stuck!


#5

I Kept trying this code:
second_letter="M"[0]
third_letter="O"[1]
fourth_letter="N"[2]
fifth_letter="Y"[3]

This code:

fifth_letter="Y"[3]

means get the fourth letter of string "Y", but string "Y" has only one letter, and that is why you get index out of range error.


What does it mean by "the fifth letter is not "MONTY"[5]!" ?

It means that "MONTY"[5] would get the letter at index 5, which is the sixth letter. We start indexing from 0, so the first letter is at index 0, second at index 1 etc...


Remember to use the string "MONTY" (all caps!) in your code

What does this mean? Even though I USED all caps in my code. Help? :frowning:

It means that you should print the fifth letter of string "MONTY", not of string "M" or "O".


#6

Kind of angry I think Ill quite code academy and Ill go to coursera because here it seems they are more interested in making things difficult for you instead of helping you learn. It states that you cannot show an answer without an explenation but Im here trying to solve what they are asking me for without any PROPER explenation.
""
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!)

It shows me the error:
Remember to use the string "MONTY" (all caps!) in your code

Ive done it in line 13 as it was said but I feel like im playing riddle me this riddle me that. IM VERY DESSAPOINTED


#7

Please post your code.


#8

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

I dont understand what they are asking me do they want a count formula?!?! im at a lost please help

SO IM STOCK AND NO ONE IS ATTENDING MY QUESTION THIS IS GREAT, ILL RECOMMEND CODE ACADEMY TO EVERY ONE I PROMISE. GOOD BYE


#9

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