Answer:
Explanation:
I do not have the files listed in the question so I have made two test files with the same names. This code is written in Python, we are assuming that the names on each file are separated by newlines.
f1 = open("GirlNames.txt", 'r')
f1_names = f1.read()
f1_names_list = f1_names.split('\n')
f2 = open("BoyNames.txt", 'r')
f2_names = f2.read()
f2_names_list = f2_names.split('\n')
print(f1_names_list)
print(f2_names_list)
boy_or_girl = input("Would you like to enter a boy or girl name or both: ").lower()
if boy_or_girl == 'boy':
name = input("Enter name: ")
if name in f2_names_list:
print("Yes " + name + " is in the list of most popular boy names.")
else:
print("No, it is not in the list")
elif boy_or_girl == 'girl':
name = input("Enter name: ")
if name in f1_names_list:
print("Yes " + name + " is in the list of most popular girl names.")
else:
print("No, it is not in the list")
elif boy_or_girl == 'both':
girlname = input("Enter Girl name: ")
if girlname in f1_names_list:
print("Yes " + girlname + " is in the list of most popular girl names.")
else:
print("No, it is not in the list")
boyname = input("Enter name: ")
if boyname in f2_names_list:
print("Yes " + boyname + " is in the list of most popular girl names.")
else:
print("No, it is not in the list")
else:
print("Wrong input.")