Skip to content

Latest commit

 

History

History
79 lines (72 loc) · 1.06 KB

File metadata and controls

79 lines (72 loc) · 1.06 KB

##Links

##While

i = 0
while i < 5:
    print(i)
    i += 1

0
1
2
3
4

##For

for i [0, 2, 4, 6, 8, 10]:
    print(i)

0
2
4
6
8
10

##Continue

for i in [1, 2, 3, 4, 5]:
    if i == 3:
        continue
    print(i)

1
2
4
5

##Break

for i in [1, 2, 3, 4, 5]:
    if i == 3:
        break
    print(i)

1
2

##Pass

for i in [1, 2, 3, 4, 5]:
    if i % 2 == 0:
        pass
    else:
        print(i)

1
3
5

##Try .. Except

a = 5 /0

---------------------------------------------------------------------------
ZeroDivisionError Traceback (most recent call last)
< ipython-input-489-0aec5d0a819c> in < module>()
----> 1 a = 5 /0
ZeroDivisionError: integer division or modulo by zero

try:
    a = 5 / 0
except:
    print("error")

error