why, when you start start (), cycle start () stop () start () stop (), etc. .. does it have to stop after executing the stop () function? I study how cycles work

# -*- coding: utf-8 -*- import time from math import floor m = 3 #print(n, type(n), m, type(m)) a = 20 def start(): while True: try: n = 3 print(n, type(n)) time.sleep(2) while n - 1 > 0: #print("while",n) n -= 1 if n == 1: print("n", n, type(n)) time.sleep(4) stop() while True: try: print(n) time.sleep(2) break except: print("except") time.sleep(2) except: print("1") def stop(): try: print("stop") time.sleep(4) except: print("except") 
  • 2
    And why should he stop? you only have delays, but not the end, or going beyond the limits of the cycle - danilshik
  • one
    Complete the code so that it does at least something. Or correct indents. This code does nothing. In general, yes, nothing stops in the above code. - Enikeyschik
  • 3
    If you study cycles, study them. Throw out all the business logic thrice nested while, try-except, and on the minimally reproducible fragment , determine why it works this way and not otherwise. And when it works correctly, start filling the branches and procedures with practical sense. - Lecron
  • if you understand python correctly, it performs line by line sequentially, that is, it must stop at the foot!?! What is the stop for the cycle? Or should the system exit be called as a stop or what else? - Oleg
  • one
    What foot should he stop at? Why? - Enikeyschik

1 answer 1

I found it in the open spaces

 def stop(): print("stop") return 0 flag = 1 while flag: flag = stop() 
  • the decision did not help - Oleg