convert a list to a string

Bart Nessux bart_nessux at
Fri Jan 9 04:31:16 CET 2004

Paul Rubin wrote:
> Bart Nessux <bart_nessux at> 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
> 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)

How does randint and sample differ? I was under the impression that 
sample was more random.

More information about the Python-list mailing list