본문 바로가기
PYTHON(파이썬)/파이썬 기초

예시로 배우는 파이썬 (제어문-FOR)

by eplus 2024. 10. 8.
728x90
반응형

###################################
# Python 기초 8 : 제어문 - 한줄 For
# eplus(http://www.eiot.co.kr)-나도코딩(YouTube):파이썬 코딩 무료 강의 (기본편) 참조
###################################
# 제어문

absent = [2,5]
no_book = [7]

for s in range(1,11):
    if s in absent:
        continue
    elif s in no_book:
        print("오늘 수업 여기까지...")
        break
    print("{0}, 책을 읽어봐".format(s))

# 한줄 FOR
s= [1,2,3]
print(s)
s = [i+100 for i in s]
print(s)

s = ["김", "박사", "이리"]
print(s)
s = [len(i) for i in s]
print(s)

 

728x90