본문 바로가기

Algorithm/Python

[Python] range함수 사용법

1.

range(10)

>>> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

 

2.

range(1,11)

>>> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

 

3.

range(0, 20, 2)

>>> 0, 2, 4, 6, 8, 10, 12, 14, 16, 18

 

4.

range(20, 0, -2)

>>> 20, 18, 16, 14, 12, 10, 8, 6, 4, 2