[Tutor] Generating Birthdays

Steven D'Aprano steve at pearwood.info
Wed Jun 2 01:37:18 CEST 2010


On Wed, 2 Jun 2010 08:04:13 am Benjamin Leddige wrote:
> I have to create a program that generates random birthdays while
> using lists. How do i go about doing this? Do i create two separate
> lists for for the months and days or how can i go about writing this?

If you didn't use a separate list for months and days, what could you 
do?

What would you do if you were doing this by hand? Write out the steps 
you would do by hand, and then do the same thing in Python.

E.g. this is what I would do by hand, *if* I didn't have to use lists:

To pick a random birthday, choose a random number between 1 and 365, 
then find out which date of the year (month and day) that is.

You can't do that because you have to use lists. So what would you do 
instead?


-- 
Steven D'Aprano


More information about the Tutor mailing list