#while문
'''
while 조건:
    반복할 명령
'''
i = 3
while i > 0:
    print(i)
    i -= 1 #i = i - 1
print('끝!')

a = 1
while a <= 5:
    print(a)
    a += 1

#break : 반복문을 강제로 멈추는 명령어
while True:
    print('반복')
    break

i = 2
while True:
    print(i)
    if i == 5:
        break
    i += 1

#continue : 반복을 멈추지 않고, 특정 조건일 때만 건너뛰기
n = 0
while n < 10:
    n += 1
    if n % 2 == 0:
        continue
    print(n)


print('----문제1----')
n = 1
total = 0
while n <= 100:
    total += n
    n += 1
print(total)

print('----문제2----')
sum = 0
while sum <= 50:
    num = int(input())
    if num < 0:
        continue
    
    sum += num

print(sum)

    




    

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: