I'm trying to write a program where the user types in two football teams. The teams can't be equal. The problem I have is that my program writes my error message multiple times(everytime it doesn't find it in the list). Is there anyway to get around this without completely rewrite the code??
teamlist = ["arsenal", "liverpool", "manchester", "newcastle"]
def finding_team(home_or_away):
while True:
user_input = input("Type in " + home_or_away + " team: " )
for team in teamlist:
if team.upper() == user_input.upper():
return team
else:
print("Didn't get that, try again")
continue
def team_input():
print()
hometeam = finding_team("HOME")
awayteam = finding_team("AWAY")
while hometeam == awayteam:
print("The away team can't be the same as the home team!")
awayteam = finding_team("AWAY")
return(hometeam, awayteam)
the_teams = team_input()
print("The teams you typed in are ", the_teams)