0
What wrong with the code, nonnegative
entry = 0 sum = 0 print('Enter numbers: ') while entry > 0: entry = int(input()) if entry > 0: sum += entry print (sum)
2 odpowiedzi
+ 2
your loop stop as soon as 'entry' is less or equal to zero... and you initialize 'entry' to zero, so your loop is never executed ^^
+ 1
''' if <while> and <if> conditions are the same, why using them both?
and if entry is an input, why you declare it as zero first? '''
print('Enter numbers: ')
entry = int(input())
sum = 0
if entry > 0:
sum += entry
else:
print("entry must be greater than zero!")
print(sum)