-range
a=range(10)
print(list(a))
[0,1,2,3,4,5,6,7,8,9]
-range2
a=range(1,11)
print(list(a))
[1,2,3,4,5,6,7,8,9,10]
-for
for i in range(10):
print("hello")
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
-for2
for i in range(1,11):
print(i)
1
2
3
4
5
6
7
8
9
10
-for3
for i in range(10,0,-1): #-1을 해줘야 줄어든다. 그렇지 않으면 아무일도 일어나지 않음
print(i)
10
9
8
7
6
5
4
3
2
1
-while
while i<=10 :
print(i)
i=i+1
1
2
3
4
5
6
7
8
9
10
-while2
while i>=1:
print(i)
i=i-1
10
9
8
7
6
5
4
3
2
1
-while True
while True:
print(i)
if i==10:
break
i+=1
1
2
3
4
5
6
7
8
9
10
-continue
for i in range(1,11):
if i%2 == 0:
continue #아래부분 지나가지 않고 i 증가한다
print(i)
1
3
5
7
9
-for else
for i in range(1,11):
print(i)
if i ==5 :
break
else:
print(11)
1
2
3
4
5
6
7
8
9
10
11