ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • While
    python/기본 2022. 4. 29. 17:45
    count = 0
    while count < 5:
        print(count)
        count += 1
    
    ####################################################################
    count = 0
    while True:
        if count >= 5:
            break
    
        if count == 2:
            count += 1
            continue
    
        print(count)  #
        count += 1
    
    # 0, 1, 3, 4
    ####################################################################
    count = 0
    while count < 5:
        print(count)
        count += 1
    else:
        print('done')  # while 안에서 break 에 걸리지 않고 모두 실행되면 else 를 실행하고 종료하라
    
    # 0, 1, 2, 3, 4 done

    'python > 기본' 카테고리의 다른 글

    For  (0) 2022.04.29
    Input  (0) 2022.04.29
    If  (0) 2022.04.29
    Set  (0) 2022.04.29
    Dictionary  (0) 2022.04.29

    댓글

Designed by Tistory.