convert a list to a string
Paul Rubin
http
Thu Jan 8 22:25:32 EST 2004
Bart Nessux <bart_nessux at hotmail.com> writes:
> number = random.sample(range(count), 1)
>
> This makes 'number' into a one entry list (I don't know why as 'count'
> is an integer). Is there an easy way to convert 'number' back to an
> int?
number = number[0]
But why are you using random.sample for that? And making a list of
size count, just to throw it away? It sounds like you just want a
random number between zero and count. Do that with:
number = random.randint(count)
More information about the Python-list
mailing list