Skip to main content

Getting started with Python 2

January 31, 2020   
Table of Contents

For and Else

for x in range(6):
    print(x)
    if x==2: break
else: print("over") # this line will skip if last line exists

Pass

There cannot exist any blank within for and if else. We must use pass to avoid the mistake.

for x in [1,2,3,4]:
	pass
print("over")