-5

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.

petezurich
  • 9,280
  • 9
  • 43
  • 57
  • 1
    Welcome to SO. Before asking questions, make sure that you've searched your question first. – S.B Sep 09 '22 at 18:04

2 Answers2

-1

Use sum(list)

list = [random.randint(1,9) for i in range(100)]
print(sum(list))
walker
  • 444
  • 2
  • 12
-1

Python has a built in sum function

list_sum = sum(your_list)
unltd_J
  • 476
  • 7
  • 14