Python Forum

Full Version: Print list from splitted range of numbers
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I want to create a list which contains the number upto a given limit. For eg, if max = 500
the first list should contain the first 100 numbers and then the original should get reset and then it should contain another 100 numbers and so on.

Any ideas on how to do this.??

Below mentioned is the code that I used, is there any other efficient way to do this???

min = 1
max = 100
list_one = []
for i in range(min,max+1):
list_one.append(i)
if len(list_one) >= 10:
print(list_one)
list_one = []
You can just do this with range directly:

list_one = list(range(min, max + 1))
I'm not sure what you mean by the first list and then resetting the list.