[Tutor] help with random.randint
bob gailer
bgailer at gmail.com
Wed Feb 3 07:51:36 CET 2010
David wrote:
> Hello list,
>
> I thought this was easy even for me, but I was wrong, I guess.
> Here is what I want to do: take two random numbers between 1 and 99,
> and put them into a list.
[snip]
Or you can use list comprehension:
terms = [random.randint(1, 99) for i in range(2)]
or if you seek terseness:
terms = [random.randint(1, 99) for i in 'ab']
--
Bob Gailer
919-636-4239
Chapel Hill NC
More information about the Tutor
mailing list