ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • range, enumerate, zip
    python/기본 2022. 4. 29. 18:03
    for i in range(5):
        print(i)  # 0 1 2 3 4
    
    for i in range(2, 10, 3):
        print(i)  # 2 5 8
    
    for _ in range(10):  # under score 로 실제 값을 직접 활용하지 않음을 표시
        print('hello')
    
    ####################################################################
    for i, x in enumerate(['A', 'B', 'C']):
        print(i, x)
    
    '''
    0 A
    1 B
    2 C
    '''
    
    ####################################################################
    days = ['Mon', 'Tue', 'Wed']
    fruits = ['apple', 'banana', 'orange']
    drinks = ['coffee', 'tea', 'beer']
    
    for day, fruit, drink in zip(days, fruits, drinks):
        print(day, fruit, drink)
    
    '''
    Mon apple coffee
    Tue banana tea
    Wed orange beer
    '''

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

    Closure  (0) 2022.04.29
    Function, kwargs  (0) 2022.04.29
    For  (0) 2022.04.29
    Input  (0) 2022.04.29
    While  (0) 2022.04.29

    댓글

Designed by Tistory.