0

Sum item in list

How do I sum up items of a list using a For loop E.g my_num = [1, 2, 3, 5, 2, 5]

30th Mar 2022, 4:30 AM
Roland Ogbue
Roland Ogbue - avatar
2 Réponses
+ 5
my_list = [1, 3, 4, 7] sum=0 for x in my_list: sum+=x print(sum) OR my_list = [1, 3, 4, 7] print(sum(my_list))
30th Mar 2022, 4:36 AM
NEZ
NEZ - avatar