Python Forum
Print list from splitted range of numbers
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Print list from splitted range of numbers
#1
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 = []
Reply
#2
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.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How do I calculate a ratio from 2 numbers and return an equivalent list of about 1000 Pleiades 8 15,636 Jan-05-2024, 08:30 PM
Last Post: sgrey
  How do you get Python to print just one value in a list? 357mag 3 1,007 May-17-2023, 09:52 PM
Last Post: rob101
Thumbs Down I hate "List index out of range" Melen 20 3,304 May-14-2023, 06:43 AM
Last Post: deanhystad
  find random numbers that are = to the first 2 number of a list. Frankduc 23 3,198 Apr-05-2023, 07:36 PM
Last Post: Frankduc
  List of random numbers astral_travel 17 2,693 Dec-02-2022, 10:37 PM
Last Post: deanhystad
  Remove numbers from a list menator01 4 1,322 Nov-13-2022, 01:27 AM
Last Post: menator01
  [split] why can't i create a list of numbers (ints) with random.randrange() astral_travel 7 1,508 Oct-23-2022, 11:13 PM
Last Post: Pedroski55
  IndexError: list index out of range dolac 4 1,899 Jul-25-2022, 03:42 PM
Last Post: deanhystad
  IndexError: list index out of range Anldra12 2 1,435 May-03-2022, 01:39 PM
Last Post: Anldra12
  TypeError: list indices must be integers or slices, not range Anldra12 2 2,570 Apr-22-2022, 10:56 AM
Last Post: Anldra12

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020