Enter the list in one line , Output the sum of list elements .
Enter a list... In one line .
Output the sum of the list elements in one line .
[3,8,-5]
6
a=eval(input()) print("{}".format(sum(a)))
The user enters a list and 2 It's an integer ,2 An integer as a subscript , Then the output list is mediated in 2 A sublist of elements between subscripts
The first line of string The second line is two integers , Comma interval
Intercepted sublist
HappyNationalDay 5,12
['N', 'a', 't', 'i', 'o', 'n', 'a', 'l']
a=list(input()) b,c=map(eval,input().split(",")) print(a[b:c+1])
Calculate the sum of odd numbers in the list .
Input integer list
Output the odd sum in the list
[1,2,3,4,5,6,7,9]
25
a=eval(input()) sum=0 for i in a: if i%2==1: sum=sum+i print(sum)
Enter several positive integers , Output after ascending sort .
Enter several numbers in one line , Space off .
Output list sorted in ascending order
4 5 67 3 99 2 7
[2, 3, 4, 5, 7, 67, 99]
a=list(map(eval,input().split(" "))) a.sort() print(a)