Loop

旅人·2023년 5월 30일
0

Code 1

ninjas = ['Jack', 'Ryu', 'Ken', 'Mel']

for ninja in ninjas: 
    print(ninja)


for ninja in ninjas[1:3]: 
    print(ninja)

for ninja in ninjas:
    if ninja == 'Ken':
        print(f'{ninja} - Boss!')
        break
    else:
        print(ninja)

Code 2

age = 25
num = 0

while num < age:
    if num == 0:
        num += 1
        continue
    if num % 2 == 0: 
        print(num)
    if num > 10:
        break
    num += 1

참고 : https://www.youtube.com/watch?v=GhrChSfaiu0&list=PL4cUxeGkcC9idu6GZ8EU_5B6WpKTdYZbK&index=11

profile
一期一会

0개의 댓글