+ 4

list of names and ages

how to make a list that stored in the code every time user entered data? https://sololearn.com/compiler-playground/cR94UhjX3QZP/?ref=app

13th Dec 2023, 4:27 PM
PASHA from Russia 🇷🇺
PASHA  from Russia  🇷🇺 - avatar
1 Antwort
+ 6
data = [] name = input() data.append(name) This is how you can add a value taken from the user, to a list. You can ask for multiple inputs, even inside a loop. But on Sololearn everything will reset when the program finished running. You cannot save data to start the next run with. For this, you would have to implement some kind of persistence in a real program: save the data on the filesystem, or in a database, or somewhere in the cloud.
13th Dec 2023, 4:51 PM
Tibor Santa
Tibor Santa - avatar