Home  >  Article  >  Backend Development  >  python range() method

python range() method

巴扎黑
巴扎黑Original
2016-12-07 10:47:391553browse

Everyone who uses Python knows that the range() function is very convenient. When I used it again today, I discovered a lot of details that I had seen before but had forgotten. Here we record range(), review the list slide, and finally analyze a fun bubbling program.

Record it here:

>>> range(1,5) #Represents from 1 to 5 (excluding 5)

[1, 2, 3, 4]

>>> range(1,5,2) #Represents from 1 to 5, interval 2 (not including 5)

[1, 3]

>>> range(5) #Represents from 0 to 5 (not including 5)

[0, 1, 2, 3, 4]


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Python list deduplicationNext article:Python list deduplication