Skip to content

Latest commit

 

History

History
17 lines (14 loc) · 595 Bytes

continue_while_loop.md

File metadata and controls

17 lines (14 loc) · 595 Bytes

Using continue in a while loop

continue statements are used inside loops, so when a program excutes a continue statement. The program execution immediately jumps to the start of the loop.

while True:
    name = input("Who are you?: ")
    if name != "Joe":
        continue
    print("Hello, Joe what is the password?")
    password = input()
    if password == "swordfish":
        break
print("access granted")

For the example above, if the user enters an name besides Joe the continue statement causes the program execution to jump back to the start of the loop.