Search code examples
pythonuser-input

in python, how do you put a user's input into a pre-exsitsing list variable


full section of code ex. here:

first, second, third, last =(input("test ")).split()
print("{0:s}{1:s}{2:s}{3:s}".format(last, third, second, first)))

User_guess=[0,0,0,0]
print(first)

User_guess.append[0]=first

this code tells the user to input a sentence and print it out backwards. (while splitting each word)

first, second, third, last =(input("test ")).split()
print("{0:s}{1:s}{2:s}{3:s}".format(last, third, second, first)))

User_guess=[0,0,0,0]
print(first)

User_guess.append[0]=first

this is the part where the problem occurs :line 13 in my prog. window...

User_guess.append[0]=first

. . . (i am VERY tired and have no idea what to fix) . . fYi, the variable User_guess links to a diffenrent part of the code that is affected by this. BUT the other part does NOT effect this.


Solution

  • User_guess is already a list of 4 elements so no need to use append(). Use User_guess[0]=first to store the variable first into 0'th element of User_guess list.