0
Several entries in the same variable
Hello guys, a question. Is it possible to store several entries made by the user in a list of the same variable and then print them on the screen in order of entry? I'm learning to work in python, so I would appreciate your help with an explanation in that language
4 odpowiedzi
+ 7
Yes! However, all input needs to be entered in the pop up window when you execute the program.
Multi input entered on one line, seperated by spaces:
https://code.sololearn.com/cvTdHZl4gpl1/?ref=app
Multi line input (nested lists):
https://code.sololearn.com/ckn3jO4yuPJq/?ref=app
Similar discussion:
https://www.sololearn.com/Discuss/3254453/?ref=app
+ 5
Yes, try splitting the input.
+ 3
You can review this code and observe the action.
Please read the code comments first, you need to provide the inputs before the code runs.
https://sololearn.com/compiler-playground/cfT6UG8vUTTJ/?ref=app
+ 2
You can push items into a list and recall them one at a time easily.
list = []
for i in range(5):
list.append(input())
for item in list:
print(item)
Simply alter the number in range() to reflect how many inputs you want to take.
Note the code above won't work in the sololearn codespace they way its intended but will work in other Python IDEs. You can download one for free for desktop, android or ios easily to practice.
To use the above on sololearn, enter the number of inputs in range() on separate lines in the input prompt.