PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
def calculateScores(word):
# initialize values
player= "Messi Ronaldo Karim".split()
result=[0 for _ in player]
word=list(word)
initials = "".join([p[0] for p in player])
# score has access to initial values
# and can edit them
# no need to pass this values in recursion
def score():
if not word:
return result
c=word.pop(0)
idx=initials.find(c)
if idx >-1:
result[idx]+=1
return score()
return score
# The function game returns a function
# we have to call it
word=input() or "KRAMERMARKT"
result =calculateScores(word)()
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run