Introduction to the usage of range

零下一度
Release: 2017-06-27 13:12:09
Original
3374 people have browsed it

range usage

Function prototype: range(start, end, scan):

Parameter meaning:

start: counting starts from start. The default is to start from 0. For example, range (5) is equivalent to range (0, 5);

end: the technology ends at end, but does not include end. For example: range (0, 5) is [0, 1, 2, 3 , 4] No 5

scan: The distance between each jump, the default is 1. For example: range(0, 5) is equivalent to range(0, 5, 1)
Example
>>> range(5) #Represents from 0 to 5 (excluding 5)
[0, 1, 2, 3, 4]
>>> range(0,5) #Represents from 0 to 5 (excluding 5)
[0, 1, 2, 3, 4 ]
>>> range(1,5) #Represents from 1 to 5 (excluding 5)
[1, 2, 3, 4]
>>> range( 1,5,2) # stands for from 1 to 5, with an interval of 2 (excluding 5)
[1, 3]

The above is the detailed content of Introduction to the usage of range. For more information, please follow other related articles on the PHP Chinese website!

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