'how do I add this list up without using Sum()
I want to add this up without using sum() but nothing has worked so far.
list = []
n = int(input("How mnay numbers do you want to input?: "))
for i in range(0, n):
nums = int(input())
list.append(nums)
Solution 1:[1]
You don't need a list. Just use a variable, and keep adding as new numbers are entered
n = int(input("How mnay numbers do you want to input?: "))
total_sum = 0
for i in range(n):
# 'x += y' is the same as x = x+y
total_sum += int(input())
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | foderking |
