+ 1

How to append user input (if possible)

i am trying to write input code that appends user input to a list Input("add your name here"): names.append(input()) something like that. i tried many combinations. is there another way to do it that i lack knowledge of?

11th Sep 2018, 4:09 PM
Borwonyc
Borwonyc - avatar
2 ответов
+ 2
perhaps you want Python code yes it is possible and frequenctly used you can do it many ways like, names_list=["Ram","Shyam","Mohan"] print(names_list) name=input("add your name to the list: ") names_list.append(name) print( names_list )
11th Sep 2018, 5:56 PM
Sandeep Chatterjee
+ 3
Hi Borwonyc, You did not assign any language to your question, so here is a solution in JavaScript. Get the value of the input inserted by the user user and output the input to any box you given id or class attribute: input = document.getElementById("idOne").value; document.getElementById("idTwo").innerHTML += (input); .value; takes the value of the input tag id. https://www.w3schools.com/jsref/prop_text_value.asp //_ To append and output in JavaScript you need to assign the plus operator before the is operator: += Have a look at this code, Hope it helps👍: https://code.sololearn.com/W71eBBThSF9z/?ref=app
11th Sep 2018, 4:58 PM
🌴Vincent Berger🌴
🌴Vincent Berger🌴 - avatar