I'm using python 3.6
when I use the range function in Python console, it didn't return an array, instead it shows the wording itself:
range(1, 5)
range(1,5)
print(range(1,5))
range(1,5)
How can I show the array?
I'm using python 3.6
when I use the range function in Python console, it didn't return an array, instead it shows the wording itself:
range(1, 5)
range(1,5)
print(range(1,5))
range(1,5)
How can I show the array?
The range()
function in Python 3 returns an iterator, something you can iterate on, so you can use it as:
for x in range(1, 5):
print(x)
This iterator returns one value at a time, so it can be more memory efficient.
If you want to get a list, you can use this code:
list(range(1,3))