Step 2 – generate a set of birthday
One birthday is fine, but we need to be able to deal with more than one.
The birthday paradox says that in a set of 23 birthdays, the chances are that more than one will be the same.
So we need to create a set of 23 birthdays
To do this we'll use a data structure called an array. This lets us store more than one number in the same variable name. Which is clever
- You need to change your program to match the screenshot
Watch the indentation
- set up a blank array with birthdays = []
Note: square brackets
- use a for loop to repeat 23 times
- each time you create a date, append it (add it) to the array called birthdays
- change the print line to print the array of birthdays
- Run your program to check it works (Run > Run module). You should get a list of 23 birthdays
Check to see if any of the birthdays are the same
Remember, there might not be a match! There's a greater than 50% chance that there will be, but it's not guaranteed.
Try running your program a few times. You should get matches more often than not.