pass
-
Python WhileComputer Science/Basic Programming with Python 2021. 11. 13. 22:11
While 앞에서 언급된 for loop과 거의 유사한 while loop이다. 코드는 아래와 같다. while condition: code contition 이 True라면, 코드블록을 반복하는 구조이다. 예를들어보자. i = 0 while i 0: pass else print("greater than 0") break는 loop을 끝낼 때 사용한다. i = 0 while True: print(i) if i > 3: break; i += 1 0 1 2 3 4 continue는 현재 실행하는 iteration을 건너뛰고 실행할 수 있다. i = 0 while True: print(i) i += 1 if i > 10: break if i % 2 == 0: i += 1 continue 0 1 3 5 7 9 11