In the output there is a space between the colon : and Enter. Like:…
Question In the output there is a space between the colon : and Enter. Like:… In the output there is a space between the colon : and Enter. Like:Jordyn, Enter’boy’,’girl’, or’both’: Enter(wrong) has a space – there should be no space between the ‘both’:Enter(right) according to Output for the code Code:# Creating two empty listboysList=[]girlsList=[] # Opening and reading the GirlNames.txtboyFile=open(“BoyNames.txt”,”r”)# Loop to iterate through the file GirlNames.txtfor names in boyFile: output=names.rstrip(“n”) # Append lines to list boysList.append(output) # Close the fileboyFile.close() # Opening and reading the GirlNames.txtgirlFile=open(“GirlNames.txt”, “r”)# Loop to iterate through the file GirlNames.txtfor names in girlFile: output=names.rstrip(“n”) # Append lines to list girlsList.append(output) # Close the filegirlFile.close() #Ask the user if they want to enter boy, girl or bothenter=input(“Enter ‘boy’, ‘girl’, or ‘both’:n”) if enter==’boy’: boyName=input(“nEnter a boy’s name:”) if boyName!=””: # Check the name is in the Boy’s List if boyName in boysList: print(“{} was a popular boy’s name between 2000 and 2009.”.format(boyName)) else: print(“{} was not a popular boy’s name between 2000 and 2009.”.format(boyName)) elif enter==’girl’: girlName=input(“Enter a girl’s name:”) if girlName!=””: #Check if the name is in the Girl’s List if girlName in girlsList: print(“{} was a popular girl’s name between 2000 and 2009.”.format(girlName)) else: print(“{} was not a popular girl’s name between 2000 and 2009.”.format(girlName)) #User input both names if enter==’both’: boyName=input(“nEnter a boy’s name:”) if boyName!=””: if boyName in boysList: print(“{} was a popular boy’s name between 2000 and 2009.”.format(boyName)) else: print(“{} was not a popular boy’s name between 2000 and 2009.”.format(boyName)) Computer Science Engineering & Technology Python Programming CIT 202 Share QuestionEmailCopy link Comments (0)


