Number 1
a = [20, -30, 50, 70, -10]
sum = 0
for i in range(len(a)) :
if a[i] < 0 :
break
sum = sum + a[i]
print(sum)
Number 2
a = [20, -30, 50, 70, -10]
sum = 0
for i in range(len(a)) :
if a[i] < 0 :
continue
sum = sum + a[i]
print(sum)
a = [20, -30, 50, 70, -10]
sum = 0
for i in range(len(a)) :
if a[i] < 0 :
sum = sum + a[i]
print(sum)
© 2024 OneMinuteCode. All rights reserved.