]> projects.mako.cc - babynames_answers/blob - challenge_5.py
renamed files
[babynames_answers] / challenge_5.py
1 # 5. How many boys names are also girls names? How many girls names are also
2 #    boys names?
3
4 # Note: these are asking the same question! The result from the code below
5 # should convince you of that.
6
7 import ssadata
8
9 boysNameAlsoGirlsName = 0
10 for boysName in ssadata.boys.keys():
11     if boysName in ssadata.girls.keys():
12         boysNameAlsoGirlsName = boysNameAlsoGirlsName + 1
13
14 print("There are " + str(boysNameAlsoGirlsName) + " boys names that are also girls names.")
15
16 girlsNameAlsoBoysName = 0
17 for girlsName in ssadata.girls.keys():
18     if girlsName in ssadata.boys.keys():
19         girlsNameAlsoBoysName = girlsNameAlsoBoysName + 1
20
21 print("There are " + str(girlsNameAlsoBoysName) + " girls names that are also boys names.")
22
23

Benjamin Mako Hill || Want to submit a patch?