Try to make forward and backward infinity counter | Sololearn: Learn to code for FREE!

+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

10/27/2021 9:04:56 PM

Maks Bers

12 Answers

New Answer

+5

Your counter stopped because it met the condition of the while loop. Your else condition is not nested, so it won't loop.

+3

I am wondering for what purpose are you creating an infinite loop?

+2

Thanks Rik Wittkopp! Now it’s work) https://code.sololearn.com/c1Vp1Q4jAmu8/?ref=app

+2

Vasiliy I making blinking for lightmatrix

+1

Maks Bers has already started preparing for the New Year holidays? Happy coding! ☺️

+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!

+1

Maks Bers oh yes, programming is my outlet, to which I have been devoting my free time for several years now.

+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

+1

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. ☺️

+1

Vasiliy truly so

+1

Code simplified https://code.sololearn.com/c9I69TEvos5r/?ref=app

-3

Don't expect people to put effort into helping you if you're not even willing to put any effort into asking your question. https://www.sololearn.com/Content-Creation-Guidelines? https://code.sololearn.com/Wv5gTHy1N6Ji/?ref=app https://www.sololearn.com/discuss/1316935/?ref=app https://code.sololearn.com/W3uiji9X28C1/?ref=app https://www.sololearn.com/discuss/333866/?ref=app