What am I doing wrong?


Strings & Console Output Exercise 1.4 Access by Index

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

It says 'MONTY' is not defined.


Hello :slight_smile:

MONTY <- object called MONTY
"MONTY" <- string, plain text "MONTY"

Just like when you create an object:

name = "Maciej"

name is an object called name and "Maciej" is just a text, nothing more.

If you want to use MONTY as a text (just like in this exercise) you have to use "MONTY" :slight_smile: .


Hola, te dejo el enlace para revisión ya que no comprendo como me pide la posición 5 de una cadena con solo 4 posiciones.....?


Desde ya gracias!



last lesson is my code rong
print len(my_string)
print my_string.upper()
i kept douple and tripple cheking it and nothing
anybody else use the rasberrypi for this


here on the web sit you dont need brackets(dont know why)

string is characters not numbers by the way.

but using a external interpreter you need to add extra brackets like so:

my_string= "My name is John"
print ((my_string),len(my_string))
print (my_string.upper())

My name is John 15