본문 바로가기
프로그래밍/python

python while 문

by 코끼리_땃쥐 2022. 1. 12.
반응형

while 사용법

 

while True:

    print("hello")

 

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

 

count = 0

while True:

    count += 1

    print(count)

    if count > 100:

        break

 

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

반응형

'프로그래밍 > python' 카테고리의 다른 글

pyside6 ui파일 파이썬 코드로 변환법  (0) 2022.02.03
python cv2 로 이미지 파일 열기  (0) 2022.01.12
파이썬 반복문  (0) 2021.11.25
파이썬 빌드(exe파일)  (0) 2021.11.17
pyside ui to py  (0) 2021.11.16

댓글