When function1 is successfully finished then run function2. But this need to be in function2, not as if statement outside of functions. How to call success finish of function1?
import time def function1(): print ('This is function1!') time.sleep(5) print ('Function1 is successful') function1() def function2(): if function1 is success #this part I don't get (How to write this line?) print ('This is something about function1') else: pass function2()
Use a global variable. Set it in function1, and check it in function2.
function1_success = False def function1(): global function1_success # do stuff ... if success: function1_success = True def function2(): global function1_success if function1_success: # do stuff ...