I'm trying to create a program that makes a list with what the user type on the input, but there is a problem, the code identifies the elements from the list like a variable (i think so), it shows the next error:
>NameError: name '(word)' is not defined
¿How i fix this?
lst = [] number = int(input("How many words you will put?: ")) for i in range (number): x=(input("Enter words: ")) lst.inster(i,x) print(lst)
Gavin Edwards
Lurk more.
Caleb Nelson
...
Nathan Cooper
Are you using python2? Because input evaluates what you put in, you need to use raw_input for the words.
Charles Flores
No, i'm using python 3
Parker Reed
Dude your shit is scrambled as fuck. Go read a book.
Ethan King
how do you spell insert?
Jace Stewart
lst.append(i)
Bentley Hughes
it should be
lst = [] number = int(input("How many words you will put?: "))
for i in range (number): x = input("Enter words: ") lst.append((i,x))
print(lst)
Jason Morris
Also don't indent the lines
Logan Garcia
lst.append can't take two arguments I think
Evan Rodriguez
It's a tupple
Sebastian Reed
You are right, sorry
William Morgan
I'm already write it right, that's not the problem
That don't work
Mason Murphy
If you are using 2.x you need to use raw_input not input
Colton Scott
this worked for me just fine
lst = [] number = int(input("How many words you will put? ")) for i in range(number): x = (input("Enter words: ")) lst.append((i, x)) print(lst)
Ethan Bell
I am using 3.6
Xavier Lopez
look
Isaiah Turner
>How many words you will put? breddy gud zindags
Adam Hughes
>inster
Parker Brooks
Thanks so much!!
Gavin White
>assuming new programmers are using legacy python 2 LOL.