Kent Johnson wrote:
jrlen balane wrote:
basically, i'm going to create a list with 96 members but with only
one value:
is there a shorter way to write this one???
[1] * 96
Just a note on this ---
This will work fine for immutable types (such as integers or strings).
But you can get into trouble i
Smith, Jeff wrote:
For all the talk of Python only having one way to do something which is
why it's so much better than Perl, I've counted about 10 ways to do this
:-)
Knowing you said this at least half in jest, I still feel the need to
comment.
In any programming language, you have flexibility
> 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???
Hi Jrlen Balana,
I wanted to ask: why do we want to make a list of 96 members, with the
same value? This s
ubject: Re: [Tutor] a shorter way to write this
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
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 (-:
___
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???
[1] * 96
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tut
A comprehension and range?
#
>>> list1 = [1 for x in range(0,96)]
>>> len(list1)
96
#
Thanks,
Ryan
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of jrlen balane
Sent: Friday, March 25, 2005 2:03 PM
To: Tutor Tutor
Subject: [Tutor] a sh
a, so thats the way to do it, a list comprehension, thanks for the info...
On Fri, 25 Mar 2005 14:10:41 -0500, Gabriel Farrell <[EMAIL PROTECTED]> wrote:
> how about
>
> manyones = [ 1 for x in range(96) ]
>
>
> On Sat, Mar 26, 2005 at 03:02:34AM +0800, jrlen balane wrote:
> > basically,
how about
manyones = [ 1 for x in range(96) ]
On Sat, Mar 26, 2005 at 03:02:34AM +0800, 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???
> ___
Hi,
On Mar 25, 2005, at 2:02 PM, 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]
You might want to use a list comprehension like:
[1 for i in range(96)]
-Pete
___
Tutor maillist -
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@python.org
http://mail.python.org/mailman/listinfo/tutor
11 matches
Mail list logo