convert a list to a string
Bart Nessux
bart_nessux at hotmail.com
Thu Jan 8 22:36:04 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)
Forgot to say thanks! the number[0] thing is great!
More information about the Python-list
mailing list