2.12.4 break(跳出)和continue(跳过)
# continue 仅终止内循环 放遇到Lucy时 跳过;继续下个循环
boys=['mike','jack','tom']
girls=['lily','lucy','mary']
for boy in boys:
for girl in girls:
if girl == 'lucy':
continue
print('%s kiss %s'%(boy,girl))
'''
mike kiss lily
mike kiss mary
jack kiss lily
jack kiss mary
tom kiss lily
tom kiss mary
'''
# break 仅终止内循环
print('---------------------')
boys=['mike','jack','tom']
girls=['lily','lucy','mary']
for boy in boys:
for girl in girls:
if girl == 'lucy':
break
print('%s kiss %s'%(boy,girl))
'''
---------------------
mike kiss lily
jack kiss lily
tom kiss lily
'''