Sum of postive numbers in python

Description

Python program to get input n and n postive integers (skip the negative number), then compute the sum of postive integers
Input:
5
6 7 2 -8 1 8
Ouput:
24

Solution

sum1=0
num=int(input("Enter number:"))
while(num>=0):
    sum1+=num
    num=int(input("Enter number:"))
print(sum1)

    

Explanation

since 1 is always true, input() statement gets input from user continously,
if user enters a negative number it exit from while loop using break statement.