We often encounter a situation when we need to take number/string as input from user. In this article, we will see how to get as input a list from the user.
Input : n = 4, ele = 1 2 3 4 Output : [1, 2, 3, 4] Input : n = 6, ele = 3 4 1 7 9 6 Output : [3, 4, 1, 7, 9, 6]
Code #1: Basic example
Code #2: With handling exception
Code #3: Using
Code #4: List of lists as input
- Take Matrix input from user in Python
- How to input multiple values from user in one line in Python?
- Python | Find all close matches of input string from a list
- Python | Fetch your gmail emails from a particular user
- User-defined Exceptions in Python with Examples
- Taking multiple inputs from user in Python
- Python | User groups with Custom permissions in Django
- Fetch top 10 starred repositories of user on GitHub | Python
- Python | Convert list of tuples to list of list
- Python | Convert list of string to list of list
- Python program to create a list of tuples from given list having number and its cube in each tuple
- Python | Pair and combine nested list to tuple list
- Python | Find maximum length sub-list in a nested list
- Python | Add list elements with a multi-list based on index
- Python | Replace elements in second list with index of same element in first list
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.