If you are using range to create a list with consecutive numbers, you can use the following methods:
list(range(5))
If the purpose is not a list but a numpy matrix,
import numpy
numpy.array(range(5))
and so on.
Additional information: November 26, 2017
A = [ ]
idx = 0
while idx <4:
A.append(idx+1)
idx+=1
print(A)
© 2025 OneMinuteCode. All rights reserved.