python range() method

巴扎黑
Release: 2016-12-07 10:47:39
Original
1602 people have browsed it

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]


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!