[Tutor] a shorter way to write this

Ryan Davis ryan at acceleration.net
Fri Mar 25 20:12:27 CET 2005


A comprehension and range?

#
>>> list1 = [1 for x in range(0,96)]
>>> len(list1)
96
#

Thanks,
Ryan 

-----Original Message-----
From: tutor-bounces at python.org [mailto:tutor-bounces at python.org] On Behalf Of jrlen balane
Sent: Friday, March 25, 2005 2:03 PM
To: Tutor Tutor
Subject: [Tutor] a shorter way to write this

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???
_______________________________________________
Tutor maillist  -  Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor



More information about the Tutor mailing list