Count wins and losses for each team in a league Here is the problem.
Repeatedly ask the user to enter game scores in a format like team1 score1 - team2 score2. Store this information in a dictionary where the keys are the team names and the values are tuples of the form (wins, losses).
Here is my Solution, what can I change for the better in it?
number_of_games = int(input(&quot;Enter the total number of Games: &quot;))
team_wins_and_loses = {}
for _ in range(number_of_games):
  team1, score1, __, team2, score2 = input(&quot;Enter the game results(Note that the name of the team must be a single word, without spaces):&quot;).split()
  team1_result, team2_result = ((1, 0), (0, 1)) if int(score1) &gt; int(score2) else ((0, 1), (1, 0))
  if team1 not in team_wins_and_loses:
    team_wins_and_loses[team1] = team1_result
  else:
    updated_result = (team_wins_and_loses[team1][0] + team1_result[0], team_wins_and_loses[team1][1] + team1_result[1])
    team_wins_and_loses[team1] = updated_result

  if team2 not in team_wins_and_loses:
    team_wins_and_loses[team2] = team2_result
  else:
    updated_result = (team_wins_and_loses[team2][0] + team2_result[0], team_wins_and_loses[team2][1] + team2_result[1])
    team_wins_and_loses[team2] = updated_result
  print(team_wins_and_loses)
Please always use 4 spaces to indent when using Python.

Rather than the verbose name team_wins_and_loses we could use team_results.

Rather than adding both values of the tuple we should focus on adding 1 win to the winning team, and 1 lose to the losing team.
winner[0] += 1
loser[1] += 1


We can change your turnery to pick the wining or losing team, and then extract the value with the correct default.
winning_team, losing_team = (
    (team1, team2)
    if int(score1) &gt; int(score2) else
    (team2, team1)
)
if winning_team not in team_results:
    winner = team_results[winning_team] = [0, 0]
else:
    winner = team_results[winning_team]
# same for losing team


We can use dict.setdefault to remove the need for the if.
winner = team_results.setdefault(winning_team, [0, 0])


We can use collections.defaultdict to make interacting with team_results much cleaner, rather than using dict.setdefault.
def default_scores():
    return [0, 0]

team_results = collections.defaultdict(default_scores)
# ...
team_results[winning_team][0] += 1



import collections


def default_scores():
    return [0, 0]


team_results = collections.defaultdict(default_scores)
number_of_games = int(input(&quot;Enter the total number of Games: &quot;))
for _ in range(number_of_games):
    team1, score1, __, team2, score2 = input(&quot;Enter the game results(Note that the name of the team must be a single word, without spaces):&quot;).split()
    winner, loser = (
        (team1, team2)
        if int(score1) &gt; int(score2) else
        (team2, team1)
    )
    team_results[winner][0] += 1
    team_results[loser][1] += 1
    print(team_results)