0
for Loops for loops allow you to easily iterate through lists. Given a list of numbers, calculate their sum using a for loop.
help me out please! this is what ive tried x = [42, 8, 7, 1, 0, 124, 8897, 555, 3, 67, 99] sum = 0 for x in list : sum += 1 print(sum) i couldnt pass throught this one
4 Answers
+ 4
sum+=x
+ 2
Thank you very much!!
+ 1
There is a built-in function in Python for this purpose. You can use just this code as I used:
x = [42, 8, 7, 1, 0, 124, 8897, 555, 3, 67, 99]
print(sum(x))
# the 'sum' is a built-in function in Python
+ 1
Thank you Behzad Soleimani Neysiani