LearnPy Hub
← Loops problems
Easy

Stop at a Negative

Read integers one per line. Add them up until you read a negative number (do not add it), then print the total. Use break.

Input

Integers, the last one negative.

Output

One integer.

Sample 1

Input
1
2
3
-1
Output
6

Sample 2

Input
-5
Output
0
solution.py
Output appears here
Stop at a Negative · Python practice problem · LearnPy Hub