I am trying to convert a range to list.
nums = []
for x in range (9000, 9004):
nums.append(x)
print nums
output
[90
For efficiency reasons, Python no longer creates a list when you use range. The new range is like xrange from Python 2.7. It creates an iterable range object that you can loop over or access using [index].
If we combine this with the positional-expansion operator *, we can easily generate lists despite the new implementation.
[*range(9000,9004)]
In Python 2, range does create a list... so:
range(9000,9004)