LIST()
The list() function in Python is a built-in constructor used to create a new list object from an iterable, such as a string, tuple, range, or the result of a map() operation. In the example numbers = list(map(int, input().split())), the list() function converts the mapped values into an actual list. First, input().split() breaks the user’s input into separate string elements. Then map(int, ...) converts each of those string elements into integers. Finally, list() collects all of those integer values into a list. This makes list() an essential tool for turning iterable data into a fully usable list structure in Python.
numbers = list(map(int, input().split()))
print(numbers) # Output: [1, 2, 3, 4, 5]
* INPUT
1 2 3 4 5
* OUTPUT
[1, 2, 3, 4, 5]
* The MAP() function will convert each item from a string to an integer, and
LIST() will create a list of these numbers:Last updated