본문 바로가기
language/Python

[Python] 파이썬 Continue 와 Break ( 제어문 )

by By the Ronys 2020. 8. 27.
반응형

absent = [2, 5] #결석
no_book = [7]
for student in range(1, 11) : # 1~10까지 있음
if student in absent :
continue # continue가 되면 아래있는 문장을 실행시키지 않고 다음 반복문 실행을 시킴
elif student in no_book :
print("오늘 수업 여기까지, {0}은 교무실로 따라와".format(student))
break # 반복문을 정지시키고 종료하는 것
print("{0}, 책을 읽어봐".format(student))

 

댓글