Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 create list from repeated pattern in python
I would like to create a list in Python3, which look like this

L = [(0,(0,1,2,3,4)), (1, (5,6,7,8,9)),(2,(10,11,12,13,14))......) 
lets call it
L= [(i,(j1,j2,j3,j4,j5),...)
The important is that the pattern keep on repeating till the j5 reaches 740231 Huh

Any suggestions would be very much appreciated.

Many thanks,
You could use list comprehension
L = [pattern(i) for i in range(n)]
Quote:L = [(0,(0,1,2,3,4)), (1, (5,6,7,8,9)),(2,(10,11,12,13,14))......)

I'm not going to go all the way out to 740 thousand, but it is a simple set of fors
import pprint


## use a while instead of this for and exit
## when the condition is met
for ctr in range(10):
    for ctr_2 in range(5):
        inner_ctr += 1
    a_list.append((ctr+1, tuple(sub_list)))


Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Create a program that PING a list of IPs skaailet 7 338 Mar-26-2020, 10:46 PM
Last Post: snippsat
  How to tabulate correctly repeated blocks? Xiesxes 4 394 Mar-21-2020, 04:57 PM
Last Post: Xiesxes
  Create a list of co-ordinates from Mouse press events Jagruthi 0 179 Mar-12-2020, 08:46 AM
Last Post: Jagruthi
  create a list of object with a list of character studenthch 0 191 Feb-12-2020, 08:43 AM
Last Post: studenthch
  send repeated messages with apscheduler pylab 1 352 Jan-04-2020, 08:43 PM
Last Post: snippsat
  Create a dictionary from a list klllmmm 3 423 Oct-06-2019, 05:50 PM
Last Post: Gribouillis
  How to create a list with all values being zero 357mag 4 489 Jul-14-2019, 03:43 PM
Last Post: ThomasL
  Create new list from another list based on condition khalidreemy 1 509 Jun-11-2019, 10:21 AM
Last Post: buran
  How to create meshgrid with non-integer stepsize of list elements? dazzabaijan 1 587 Mar-11-2019, 02:00 AM
Last Post: ichabod801
  modify line in file if pattern found in list. kttan 1 640 Dec-10-2018, 08:45 AM
Last Post: Gribouillis

Forum Jump:

Users browsing this thread: 1 Guest(s)