프로그래밍/python

python while 문

코끼리_땃쥐 2022. 1. 12. 22:58

while 사용법

 

while True:

    print("hello")

 

을 사용하게 되면 무한하게 hello 라고 출력이 됨

 

count = 0

while True:

    count += 1

    print(count)

    if count > 100:

        break

 

count가 100이상 일시 탈출 할 수 있게 break를 걸어줌으로써 무한 반복문을 탈출하게 됨