Python: How to create a list from user input.

How to make a list from user input.

How to get create list from user input.

 

 Below you'll learn how to make a list from user input.

Get a list from user input with range function:

How many elements:3
>1
[1]
>2
[1, 2]
>3
[1, 2, 3]

Process finished with exit code 0

Get a list from user with while loop:

Enter element for Loop 1 >> 1
Enter element for Loop 2 >> 2
Enter element for Loop 3 >> 3
Enter element for Loop 4 >> 4
Enter element for Loop 5 >> 5
List has elements [1, 2, 3, 4, 5]

Process finished with exit code 0

Simply one liner:

Good method if we don't care what type of input we want user to enter.


Enter 1st item:first
Enter 2nd item:second
Enter 3rd item:third
Your list elements: ['first', 'second', 'third']

Process finished with exit code 0

You can donate me so I can afford to buy a coffee myself, this will help me to keep going and create more content that you find interesting.


Many thanks
Stay Happy and Keep Coding :-)
 
 
Best selling book for Python beginners:

Comments