I am using a for loop to fill a list with 100 random numbers. I want to add those numbers once the list is complete and I cannot figure out how to do that. I am pretty sure it is something simple that I have just overlooked but it is driving me crazy that I can't get it to work.
CodePudding user response:
Use sum(list)
list = [random.randint(1,9) for i in range(100)]
print(sum(list))
CodePudding user response:
Python has a built in sum
function
list_sum = sum(your_list)