Получить ввод списка от пользователя в Python
a = list(map(int,input("\nEnter the numbers : ").strip().split()))
Faithful Flamingo
a = list(map(int,input("\nEnter the numbers : ").strip().split()))
# number of elements
n = int(input("Enter number of elements : "))
# Below line read inputs from user using map() function
a = list(map(int,input("\nEnter the numbers : ").strip().split()))[:n]
print("\nList is - ", a)
lst = [ ]
n = int(input("Enter number of elements : "))
for i in range(0, n):
ele = [input(), int(input())]
lst.append(ele)
print(lst)
input_string = input("Enter a list element separated by space ")
list = input_string.split()
print("Calculating sum of element of input list")
sum = 0
for num in list:
sum += int (num)
print("Sum = ",sum)
input_string = input('Enter elements of a list separated by space ')
print("\n")
user_list = input_string.split()
# print list
print('list: ', user_list)
# convert each item to int type
for i in range(len(user_list)):
# convert each item to int type
user_list[i] = int(user_list[i])
# Calculating the sum of list elements
print("Sum = ", sum(user_list))