[Tutor] a shorter way to write this

Sean Perry shaleh at speakeasy.net
Fri Mar 25 20:19:55 CET 2005


jrlen balane wrote:
> basically, i'm going to create a list with 96 members but with only one value:
> 
> list1[1,1,1,1...,1]
> 
> is there a shorter way to write this one???

def generateN(n):
     while 1:
         yield n

I'll leave the actual list creation up to you (-:


More information about the Tutor mailing list