X-Git-Url: https://projects.mako.cc/source/babynames_answers/blobdiff_plain/35439ff865dffd22b1358589da0110d5d789e81f..d5d8fd8702a5e22f4d19976d2e5661e4357988d0:/challenge_5.py diff --git a/challenge_5.py b/challenge_5.py new file mode 100644 index 0000000..1218f8b --- /dev/null +++ b/challenge_5.py @@ -0,0 +1,23 @@ +# 5. How many boys names are also girls names? How many girls names are also +# boys names? + +# Note: these are asking the same question! The result from the code below +# should convince you of that. + +import ssadata + +boysNameAlsoGirlsName = 0 +for boysName in ssadata.boys.keys(): + if boysName in ssadata.girls.keys(): + boysNameAlsoGirlsName = boysNameAlsoGirlsName + 1 + +print("There are " + str(boysNameAlsoGirlsName) + " boys names that are also girls names.") + +girlsNameAlsoBoysName = 0 +for girlsName in ssadata.girls.keys(): + if girlsName in ssadata.boys.keys(): + girlsNameAlsoBoysName = girlsNameAlsoBoysName + 1 + +print("There are " + str(girlsNameAlsoBoysName) + " girls names that are also boys names.") + +