Monty string test



i seem to be struggling with this piece of code for the string data type.
This is my code:
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 = "MONTY"[4]
print fifth_letter

The message i get is:
SyntaxError: EOF while scanning triple-quoted string literal

any help would be appreciated. Thank you



Hello Daniel,

are you doing this on Codecademy or on a Python installation? Your code is OK and should work.

EDIT: If it's the latter, could you paste the complete error message?


hi there thank you for your reply. i am using the codeacademy terminal. it should be working. what does the error mean?


problem fixed. i added triple quotation marks after the print function.

  • What lesson are you on?
  • Is that your complete code, or is it an excerpt?


heredoc = """
     This is a Python 'here document', or triple quoted string literal.
     It is basically pre-formatted text that can take as many lines
     as we need, and can be assigned to a variable.

When not assigned to a variable, it is a multiline comment. Under normal conditions we do not often have a call for such a construct, but it does come up from time to time. Not here, though,

fifth_letter = "MONTY"[4]
print fifth_letter

should be correct (assuming it answers the question in the instructions). The editor should change color on comments. That will be clue in future.


Thank you mtf, your code worked for me! :grinning: