Computer Science, asked by swathyswetha9092, 1 month ago

Repeatedly ask the user to enter team name and how many games the team has won an how many they lost .store this information in a dictionary where the keys are the team names and team names and the value are list of the form.[win loses]

Answers

Answered by Equestriadash
1

The following co‎des have been written using Python.

#creating a condition for the loop

i = 0

#creating a dictionary

team_dict = dict()

#starting the loop

while i < 1:

   tn = input("Enter the team name/Type 'n' to cancel: ")

   if tn == 'n' or tn == 'N':

       break

   else:

       w = int(input("Enter the number of wins: "))

       l = int(input("Enter the number of losses: "))

       team_dict[tn] = [w, l]

       print()

print()

#displaying the dictionary

print("Your given dictionary: ")

print()

print("Team Name\t", "Wins\t", "Losses")

for i in team_dict:

   print(i, "\t\t", team_dict[i][0], "\t\t", team_dict[i][1])

Similar questions