Detailed usage of python range() function
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: counting to the end of end, but not including 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)

Python >>> for i in range(1,5): print(i) 1 2 3 4 >>> for i in range(5): print(i) 0 1 2 3 4 >>> for i in range(0,5,2): print(i) 0 2 4 >>> for i in range(0,-5,-2): print(i) 0 -2 -4
Python video tutorial》
Note:The difference between python2 and python3:
python3 returns an iteration value:Python3
print(range(1,5)) range(1, 5) # 正确打印方法 list(range(1,5)) [1, 2, 3, 4]
Python2
>>> range(1,5) [1, 2, 3, 4]
The above is the detailed content of What does python range mean?. For more information, please follow other related articles on the PHP Chinese website!
Tutorial on merging multiple words into one word
What is the difference between pass by value and pass by reference in java
What should I do if the ps temporary disk is full?
What coin is NFT?
How to recover files emptied from Recycle Bin
Is FIL worth holding for the long term?
Java environment variable configuration tutorial
Free erp management system software