How to add multiple numbers that were typed into the output?

0

What I have so far:

for c in range(3):
    n = int(input())
    n += n #tenho quase certeza que essa parte não está certa
print(n)

How to add multiple numbers that were typed in the output ?

    
asked by anonymous 25.10.2017 / 15:21

1 answer

2

You're doing overwrite to n when you do n = int(input()) , do before:

total = 0
for _ in range(3):
    n = int(input())
    total += n
print(total)

DEMONSTRATION

Or with fewer rows / variables:

total = 0
for _ in range(3):
    total += int(input())
print(total)

Python

style :

total = sum(int(input()) for _ in range(3))
    
25.10.2017 / 15:28