You could even do: var1 = dict([(i,'') for i in xrange(1,20)])
Or if you need the key in the dictionary to be a string: var1 = dict([(str(i),'') for i in xrange(1,20)]) On Tue, Feb 8, 2011 at 12:25 PM, Richard Vézina <[email protected] > wrote: > var1={} > for i in range(19): > var1[i]='' > > Richard > > 2011/2/8 António Ramos <[email protected]> > > is there a more compact way of doing this? >> >> >> var1={'1':'','2':'','3':'','4':'','5':'','6':'','7':'','8':'','9':'','10':'','11':'','12':'','13':'','14':'','15':'','16':'','17':'','18':'','19':''} >> >> Thanks >> António >> >> >

