0
add an element in list by the user
What is the process or syntax for adding an element by the user in an existing list?
2 Answers
+ 5
You can use the list.append method. Example:
fruits = ["apple", "banana"]
user_inp = input()
fruits.append(user_inp)
Read more here:
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2433/?ref=app
+ 2
list1 = ["a", "b"]
userInput = input()
list1.append( userInput)