Answer the question
In order to leave comments, you need to log in
How to find the sum of all input elements of a list?
How to find the sum of any number of entered list items in python? (meaning numerical values).
Answer the question
In order to leave comments, you need to log in
One solution is to use the for statement
spisok = [1,2,3,4,5]
summa=0
for el in spisok:
summa += el
lst = [1,2,3,4,5,"string"]
sum([i for i in lst if str(i).isdigit()])
>>> 15
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question