+ 1

How do you calculate the sum of a list in python?(with only for loop)

list = [1, 2, 3, 4, 5, 6, 7, 8, 9] sum = 0

24th Aug 2021, 6:17 PM
reihane
reihane - avatar
3 Answers
+ 8
Loop through the list and add the current element to sum on each iteration
24th Aug 2021, 6:18 PM
Lisa
Lisa - avatar
+ 3
reihane , to get useful help from the community,  we need to see your attempt first. without having seen your code, it is difficult to find out where the issue is. => please put your code in playground and link it here thanks!
24th Aug 2021, 7:49 PM
Lothar
Lothar - avatar
+ 1
I did it thanks!
24th Aug 2021, 8:12 PM
reihane
reihane - avatar