Hello and today we will continue to solve the problem posted on codewars, if you have not yet joined codewars then I really encourage you to do so because this site is a real deal for those of you who want to master the Python programming language. In this latest chapter, we will need to write a function that takes such a list and counts the points of our football team in the championship. Rules for counting points for each match are as follows.
- if x>y – 3 points
- if x<y – 0 point
- if x=y – 1 point
We will first split the items in a list into two parts, then we will compare the first part with the second part and add up the points accordingly.
def points(games): total = 0 for points in games: c_point = points.split(':') if(int(c_point) > int(c_point)): total += 3 elif(int(c_point) == int(c_point)): total += 1 return total
The solution is short and simple, if you have a better solution then do comment on the below tweet so others can learn from you as well.
Provide your answer to this question here https://t.co/khiNS7Df2m
— whei choo (@ChooWhei) February 9, 2019