Idiomatic way of repeating items in a sequence.

John Hunter jdhunter at
Mon Jun 30 17:59:25 CEST 2003

>>>>> "alr" == alr  <anlri at> writes:

    alr> reduce(lambda l, i: l + i, [[item] * repetitions for item in
    alr> sequence])

Oops, premature hit of send key.  What I meant to say was

  seq = ['a', 'b', 'c']
  print [x for x in seq for i in range(len(seq))]


More information about the Python-list mailing list