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
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.
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
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()
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()