One-step multiples list generation?

Efrat Regev efrat_regev at yahoo.com
Tue Jan 3 13:37:04 EST 2006


Damien Wyart wrote:
> * Efrat Regev <efrat_regev at yahoo.com> in comp.lang.python:
> 
>>Suppose I have some non-numerical Foo and would like to create a list
>>of 20 Foo-s. Is there a one-step method (not a loop) of doing so?
> 
> 
> Maybe :
> 
> [ Foo ] * 20
> 
> or, more verbose,
> 
> [ Foo for _ in range(20) ]
> 
> ?
> 

Great. Thanks!



More information about the Python-list mailing list