0

Help Do the math python practice result 1, 3 6, 10, 15

Multiple results are given in test case, the result should be 15 sum = 0 while True: x = input() if x == "stop": break else: sum += int(x) print(sum)

8th May 2021, 2:34 PM
Lee 4 Code
Lee 4 Code - avatar
2 Respuestas
+ 3
Your print() is called on each iteration because it's indented such that it's part of while loop's body. Remove indentation (white space before print). Then it'll get called only once, when while loop is terminated.
8th May 2021, 2:44 PM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
+ 1
Thank you Omkar!
8th May 2021, 2:55 PM
Lee 4 Code
Lee 4 Code - avatar