+ 2

Try to make forward and backward infinity counter

i = 0 checker = 0 while checker != 1: i += 10 print(i) if i == 100: checker = 1 print('checker=1') else: i -= 10 print(i) if i == 0: checker = 0 I don’t understand why backward counter stopped when I try to create infinity loop

27th Oct 2021, 9:04 PM
Maks Bers
Maks Bers - avatar
12 ответов
+ 5
Your counter stopped because it met the condition of the while loop. Your else condition is not nested, so it won't loop.
27th Oct 2021, 10:37 PM
Rik Wittkopp
Rik Wittkopp - avatar
+ 4
I am wondering for what purpose are you creating an infinite loop?
27th Oct 2021, 11:26 PM
Solo
Solo - avatar
27th Oct 2021, 11:15 PM
Maks Bers
Maks Bers - avatar
+ 2
Vasiliy I making blinking for lightmatrix
27th Oct 2021, 11:35 PM
Maks Bers
Maks Bers - avatar
+ 2
Maks Bers has already started preparing for the New Year holidays? Happy coding! ☺️
27th Oct 2021, 11:45 PM
Solo
Solo - avatar
+ 2
Maks Bers oh yes, programming is my outlet, to which I have been devoting my free time for several years now.
28th Oct 2021, 12:05 AM
Solo
Solo - avatar
+ 2
Maks Bers almost everything new is hard for us, but passion and curiosity helps us in comprehending everything new, and over time, gaining experience, we cease to notice the difficulties that we encountered at the beginning of the path. We also did not start walking right away. ☺️
28th Oct 2021, 12:35 AM
Solo
Solo - avatar
+ 1
Vasiliy Thanks! Oh god damn it yes, already play with gift for myself in face of lego mindstorm) And you? You too happy coding!
27th Oct 2021, 11:48 PM
Maks Bers
Maks Bers - avatar
+ 1
Vasiliy awesome! For me programming is going little bit hard, but absolutely with new passion in addition to the main occupation of motion-design
28th Oct 2021, 12:15 AM
Maks Bers
Maks Bers - avatar
+ 1
Vasiliy truly so
28th Oct 2021, 12:40 AM
Maks Bers
Maks Bers - avatar
29th Oct 2021, 2:44 PM
Sushil 🛡️
Sushil 🛡️ - avatar