Python Forum

Full Version: out and back to loop
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi everyone, I don't understand how out from a loop while. I have a test loop ho test the contacts GPIO from my raspberry then the contact go to close send email (just one) and when the contact go back to open sand one email (just one) to say what he is open. Meanwhile the test loop continues. now it's worked but he sends as much mail as loop turns. somone can give me idea to solvd thet ? thank you.
To get out of a loop, you use the break statement:

num = 1
while True:
    print(num)
    num += num
    if num > 100:
        break
ok but how I go back to my loop ?