Kent,
Yes you are right. I looked at your code and that makes sense now.
Thanks for explaining that.
ALL-NEW
Yahoo! Messenger
- all new features - even more fun!
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/t
Max Noel wrote:
On Jan 23, 2005, at 22:08, Liam Clarke wrote:
Don't you mean
x=random.randint(0, lenoflist) ?? I'm assuming you want an integer.
random.randrange() returns an item (which can be a float or
whatever, but by default is an int) in the specified range. In that
case, an int betwee
On Jan 23, 2005, at 22:08, Liam Clarke wrote:
Don't you mean
x=random.randint(0, lenoflist) ?? I'm assuming you want an integer.
random.randrange() returns an item (which can be a float or whatever,
but by default is an int) in the specified range. In that case, an int
between 0 and lenoflist.
gt; >4. Re: Print record x in a file (David Holland)
> >5. on the way to find pi (Ali Polatel)
> >6. Re: on the way to find pi (Max Noel)
> >7. Re: on the way to find pi (Orri Ganel)
> >
> >
> >
> --
> >
> > Message: 1
> > Date: Sun, 23 Jan 2
i (Ali Polatel)
>6. Re: on the way to find pi (Max Noel)
>7. Re: on the way to find pi (Orri Ganel)
>
>
>
------
>
> Message: 1
> Date: Sun, 23 Jan 2005 07:46:08 -0500
> From: Kent Johnson <[EMAIL PROTECTED]>
&g
--- "Jacob S." <[EMAIL PROTECTED]> wrote:
> > This will get a random record
> > I hope you do not think the comments are
> patronising
> > but you did say you are new so I did not want to
> give
> > naked code.
> >
> > import random
> > #the above gives the program the ability to get a
> > #pseud
Jacob S. wrote:
import random
#the above gives the program the ability to get a
#pseudo random number
file = open('test.rantxt')
listcontents = file.readlines()
#gives you the file as a list of records or it did on
#(assuming each line is a record)
file.close()
lenoflist = len(listcontents)-1
#find
Jacob S. wrote:
This will get a random record
I hope you do not think the comments are patronising
but you did say you are new so I did not want to give
naked code.
import random
#the above gives the program the ability to get a
#pseudo random number
file = open('test.rantxt')
listcontents = file.r
This will get a random record
I hope you do not think the comments are patronising
but you did say you are new so I did not want to give
naked code.
import random
#the above gives the program the ability to get a
#pseudo random number
file = open('test.rantxt')
listcontents = file.readlines()
#give
This will get a random record
I hope you do not think the comments are patronising
but you did say you are new so I did not want to give
naked code.
import random
#the above gives the program the ability to get a
#pseudo random number
file = open('test.rantxt')
listcontents = file.readlines()
#gi
10 matches
Mail list logo