Source code for AutomateTheBoringStuff.Ch05.P1_birthdays

"""Birthdays

This program makes a birthday database using a :obj:`dict`.

"""


[docs]def main(): birthdays = {'Alice': 'Apr 1', 'Bob': 'Dec 12', 'Carol': 'Mar 4'} """dict: Birthdays with first name as keys and `month day` as values.""" while True: print('Enter a name: (blank to quit)') name = input() if name == '': break if name in birthdays: print(birthdays[name] + ' is the birthday of ' + name) else: print('I do not have birthday information for ' + name) print('What is their birthday?') bday = input() birthdays[name] = bday print('Birthday database updated.')
if __name__ == '__main__': main()