x ='two'if x =='one':print('It is one!')elif x =='two':print('it is two!')else:print("Unknown")# 'it is two!'
for loops
my_list =[1,2,3]for num in my_list:print(num)# 1# 2# 3for num in my_list:if num %2==0:print(num)# 2
while loops
x =0while x <5:print('x: ',x)
x+=1if x==3:print('Breaking because x==3')breakelse:print('continuing...')continue# x: 0# continuing...# x: 1# continuing...# x: 2# Breaking because x==3