num = 1 while num <= 10: print(num) num = num + 1 result: 1 2 3 4 5 6 7 8 9 10
while <조건문>:
(공백 4칸) <수행할 문장1>
<수행할 문장2>
. . .
treehit = 0 while treehit <10: treehit = treehit + 1 print("hit tree %d times." % treehit) if treehit == 10: print("OMG.. TREE IS FALLING DOWN..") result: hit tree 1 times. hit tree 2 times. hit tree 3 times. hit tree 4 times. hit tree 5 times. hit tree 6 times. hit tree 7 times. hit tree 8 times. hit tree 9 times. hit tree 10 times. OMG.. TREE IS FALLING DOWN...
나무가 넘어갑니다..