What am I doing wrong?


#1

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.


#2

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: .


#3

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.....?

https://www.codecademy.com/es/courses/python-beginner-es-uW8F7/0/4?curriculum_id=50fc7aab5fab3aa9c2002444#

Desde ya gracias!

André.


#4

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


#5

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())

RESULT:
My name is John 15
MY NAME IS JOHN