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?

20th Nov 2018, 2:08 PM
Sourav Guha
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
20th Nov 2018, 2:30 PM
Kishalaya Saha
Kishalaya Saha - avatar
+ 2
list1 = ["a", "b"] userInput = input() list1.append( userInput)
20th Nov 2018, 2:32 PM
Gordon
Gordon - avatar