list input in python
Python Program to get list size n and n elements of list, then print the elements.
Sample Input 1:
5 5 7 9 3 1
Sample Output 1:
5 7 9 3 1
Program or Solution
l=list(map(int,input("Enter array elements:").split(" "))) for i in l: print(i)
To get list of numbers separated by space, use split(" ") method.
Split() method splits the numbers as separate elements.
By default this methods are considered as string, since input() method returns string. Use map() function to convert all elements as integer and store it in list.
- sum of list in python | without using built-in function
- Average of list in python | without using built-in function
- linear search in python
- largest element in the list python | without using built-in function
- smallest element in the list python | without using built-in function
- Print all the numbers which are less than given key element from a given list.
- delete element in list python
- Revese the elements in list python
- Reverse the first half of list elements in python
- Reverse the second half of list elements in python
- list sort python
- list sort descending order python
- Python Program to sort half of the list elements in ascending order and next half in descending order.
- merging two lists in python
- Python Program to replace every element with the greatest element on right side
- circular list rotation in python