I'm trying to make a program with Python that will ask the user for the scores for 5 games. I then need the winner of each match to be printed at the end. The part I'm having an issue with is getting the right winner for each match to print. I can only use lists, for loops and if/else statements. I'm new to programming so I'm not sure what I'm doing wrong.
Description: The program will accept the number of points that each team scored in the 5 matches and print out the data along with the winner. The winning team is that one that wins the most matches. Note: It is not necessarily the team that scores the most number of points.
games = [0, 0, 0, 0, 0]
winner = ["Team 1", "Team 2"]
gamesresults = 0
team1_scores = [0, 0, 0, 0, 0]
team2_scores = [0, 0, 0, 0, 0]
matches = ["Match 1", "Match 2", "Match 3", "Match 4", "Match 5"]
for games in range(5):
team1_scores[games] = int(input("Enter the score from team 1 from match {}?".format(games+1)))
team2_scores[games] = int(input("Enter the score from team 2 from match {}?".format(games+1)))
games += 1
#the section i'm having problems with
for games in range(5):
if team1_scores[games] > team2_scores[games]:
winner = "Team 1"
else:
winner = "Team 2"
gamesresults = [team1_scores, team2_scores, winner]
#this is ok
print(" ", "Team 1", "Team 2", "Winner")
for i in range(5):
print("Matches", i+1, team1_scores[i], team2_scores[i], winner)
if team1_scores > team2_scores:
print("The Winner is Team 1")
else:
team2_scores > team1_scores
print("The Winner is Team 2")
Aucun commentaire:
Enregistrer un commentaire