[Tutor] help with random.randint

Hugo Arts hugo.yoshi at gmail.com
Wed Feb 3 10:17:59 CET 2010


On Wed, Feb 3, 2010 at 8:19 AM, David <ldl08 at gmx.net> wrote:
> Hello Bob,
>
> thanks for your comments!
>
>
> On 03/02/10 14:51, bob gailer wrote:
>
>> or if you seek terseness:
>>
>> terms = [random.randint(1, 99) for i in 'ab']
>
> Do I understand correctly that 'ab' here merely serves to produce a 'dummy
> sequence' over which I can run the for loop?
>

That is correct. you could have used any two-character sequence. I
think the range(2) call is clearer and more pythonic though. And it's
not that much longer

Hugo


More information about the Tutor mailing list