I try to exit the loop when the condition is agreed. I tried single line below:
break if a is not None else time.sleep(1)
and this one
a is not None and break
time.sleep(1)
Both do not work and throw SyntaxError, while straight forward works great.
if a is not None:
break
time.sleep(1)
While I have no problem using this method, I just want to know why the syntax above is incorrect.
source
share