i = 1
while i > 0:
print(i)
break
#break : 반복문을 강제로 멈추게 하는 명령어
i = 0
while True:
print('*')
if i == 3:
break
i = i + 1
print(i)
total = 0
num = 1
while True:
if total + num >= 100:
break
total = total + num
num = num + 1
print('총합', total, '횟수', num)
#while : 반복 횟수를 모를 때 사용
#for : 반복 횟수를 알고 있을 때 사용
print('----문제1----')
candy = 1
while True:
print(candy, "번째 사탕을 먹습니다")
if candy == 5:
print("배가 아파서 그만 먹습니다")
break
candy = candy + 1
To embed this project on your website, copy the following code and paste it into your website's HTML: