0

what is the problem in this python code..

total = 0 while True: x = int(input('Enter Number')) if x == 0: print(total) break total = total + x

2nd Feb 2019, 4:14 AM
Kaveesha Thilakarathna
Kaveesha Thilakarathna - avatar
4 Respuestas
+ 2
Kaveesha Thilakarathna Indentation is everything in Python.
2nd Feb 2019, 5:52 AM
Sachin Artani
Sachin Artani - avatar
+ 7
The problem is with indentation if I understood your code properly. You need to nest if condition inside the while loop.
2nd Feb 2019, 4:20 AM
Arushi Singhania
Arushi Singhania - avatar
+ 1
Thank you :)
7th Feb 2019, 2:40 AM
Kaveesha Thilakarathna
Kaveesha Thilakarathna - avatar
0
Thank you also :) it works now
7th Feb 2019, 2:53 AM
Kaveesha Thilakarathna
Kaveesha Thilakarathna - avatar