- 2

Python White loop Help!!

Hos do I get a sum by using White loop for N numbers

26th Dec 2019, 10:23 AM
Agam Singh
Agam Singh - avatar
3 Réponses
+ 1
How did you try to do that
26th Dec 2019, 11:02 AM
Randych
Randych - avatar
0
this is what i did : mystery_int = -7 total =0 i=1 while i <= mystery_int: total=total+1 i=i+1 print(total) this seems to only work for positive numbers but what if mystery int is -4 then it should add -4+-3+-2+-1+0
26th Dec 2019, 11:38 AM
Agam Singh
Agam Singh - avatar
0
Your i is already cannot be less or equal to negative number, so your loop won't do. I think you're approached it from the wrong side and I struggle to understand how tou intended to achieve anything that way.
26th Dec 2019, 11:56 AM
Randych
Randych - avatar