Quick actions

cmd+k|ctrl+k

Navigation

Languages

While loop 2

Snippet info

Language

Python

Visibility

public

Author

chausage

Created

2024-12-02T09:18:41.53188Z

Updated

2024-12-02T09:18:41.53188Z

x=10
while x> 0:
    while x>5:
        x=x-1 #controller, otherwise 無限loop
        if x%2:# %:Remainder, 餘數
            continue 
        print(x)
    if x==4:
        break #end/exit loop
    x=-1
        
else:
    print("This line will run when while loop is false.")
    
INFO