How can I merge the result input function to an actual table? Win gives 3 points, draw 1 and loss 0

  merge, points, python, python-3.x
class Team:
    def __init__(self, team, win=0, draw=0, loss=0, scored=0, conceeded=0):
        self.team = team
        self.win = win
        self.loss = loss
        self.draw = draw
        self.scored = scored
        self.conceeded = conceeded

    def get_points(self):
        return self.win*3 + self.draw

    def get_difference(self):

        return self.scored - self.conceeded

    def get_table_row(self):
        return (self.team + " "*(20-len(self.team)) + str(self.win) + "t" + str(self.draw) + "t" + str(self.loss) + "t" + str(self.get_difference()) + "t" + str(self.get_points()))
   
def match_results(teams):
    team1_name = input("Home team: ")
    team2_name = input("Away team: ")
    #add error handling for none-existing teams later on
    team1 = None
    team2 = None
    for team in teams:
        
        if team1_name == team.team:
            team1 = team
        if team2_name == team.team:
            team2 = team
    
    result = input("Match results: ")
    result = result.split("-")
    team1_score = int(result[0])
    team2_score = int(result[1])
       
def team_rank(team):
    return (team.get_points(), team.get_difference(), team.scored, team.team)

def main():
    Leeds = Team("Leeds", 6, 1, 2, 15, 9)
    ManU = Team("Manchester United", 5, 2, 2, 16, 12)
    Chelsea = Team("Chelsea", 3, 4, 2, 12, 15)
    teams = []
    teams.append(Leeds)
    teams.append(ManU)
    teams.append(Chelsea)
    match_results(teams)
    

main()

From results, managed by input from the user, i want to merge the results to a league table where the leader has most points. If two teams are on the same points, the best goal difference will decide who’s leading. If they’re also the same, most scored goals will decide. If all of these are the same, the first letter of each team will decide the rank (not fair, but that’s the task that is given to me).

Source: Python-3x Questions

LEAVE A COMMENT