Nathan Chan Nathan Chan - 1 year ago 76
Python Question

Break out of Loop but Still make Loop Useable

I'm a beginner to Python, so this might sound pretty easy.

Anyway, I'm a little confused on when to use

, or
. I want to have a loop where it breaks out of it, but then after all the code runs again, then the loop will run again. This is some example code:

score = 100
while True:
score + 1
# break, continue, or pass

score - 30

Basically, what I want to happen is have score go up by 1, then have it go down by 30, and then keep going up by 1.

How can I achieve this? Thanks in advance!

Answer Source
score = 100
first = True
while True:
    while True:
        score += 1
        if first:
            first = False
    score -= 30
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download