convert a list to a string
Bart Nessux
bart_nessux at hotmail.com
Thu Jan 8 22:31:16 EST 2004
Paul Rubin wrote:
> 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)
How does randint and sample differ? I was under the impression that
sample was more random.
More information about the Python-list
mailing list