How python traverses numbers in a range
Editor to share with you how python traverses a range of numbers, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!
Traverse a range of numbers
For i in [0,1,2,3,4,5]: print I * * 2for i in range (6): print I * * 2
A better way
For i in xrange (6): print I * 2
Xrange returns an iterator to traverse a range one value at a time. This approach is more memory-efficient than range. Xrange has been renamed range in Python 3.
The above is all the content of the article "how python traverses numbers in a range". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!