# Team Points in Python

## Problem Statement:

This is IPL and matches are going on. You are a programmer who writes programs to output summarized charts of matches already played.
You will be given some input and you need to print a summarized chart in descending order of points.

Points criteria->
Match won-> 2
Draw-> 1
Loss-> 0

For example
Input:
4
RR-RCB-loss
MI-KKR-loss
CSK-RR-win
GT-RCB-draw
Output:
Team: RR | Total Matches: 2 | Won: 0, Lost: 2, Draw: 0, Points: 0
Team: RCB | Total Matches: 2 | Won: 1, Lost: 0, Draw: 1, Points: 3
Team: MI | Total Matches: 1 | Won: 0, Lost: 1, Draw: 0, Points: 0
Team: KKR | Total Matches: 1 | Won: 1, Lost: 0, Draw: 0, Points: 2
Team: CSK | Total Matches: 1 | Won: 1, Lost: 0, Draw: 0, Points: 2
Team: GT | Total Matches: 1 | Won: 0, Lost: 0, Draw: 1, Points: 1

## Code to find Team Points in Python:

```''' Add teams to dictionary '''
#if team already exists in list, update the list
if team in teams:
points = teams[team]
#else set to 0
else:
points = [0,0,0]

#points[win,loss,draw]
result = result.lower()
if(result=="won"):
points[0] +=1
elif(result=="loss"):
points[1] +=1
else:
points[2] +=1

#update teams
teams[team] = points

''' calculate result to be displayed '''
def calc_result(teams):
list_res= list()

for team in teams:
won,lost,draw = teams[team]

#calculate points
points = 2*won + draw

#total matches played
total = won+lost+draw

#string to be displayed
string = f"Team: {team} | Total Matches: {total} | Won: {won}, Lost: {lost},  Draw: {draw}, Points: {points}"
list_res.append(string)

return list_res

''' main function '''
n=int(input("Number of Matches Played: "))
teams=dict()

for i in range(n):
ip = input().split("-")
# ip[0]: team played | ip[1]: against team | ip[2]: result

#for team1

#for team2, reverse the result
if(ip[2]=="win"):
elif(ip[2]=="loss"):
else:

'''result to display'''
res = calc_result(teams)

'''display the results'''
for string in res:
print(string)```