A more elegant way to do this list comprehension?

yairchu at gmail.com yairchu at gmail.com
Wed Jun 7 10:03:15 CEST 2006


> > [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7,
> > 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]
> [i+1 for i in range(8) for j in range(i+1)]
[i for i in range(9) for j in range(i)]




More information about the Python-list mailing list