-
Notifications
You must be signed in to change notification settings - Fork 1
/
examen.py
33 lines (32 loc) · 899 Bytes
/
examen.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
29
30
31
32
33
def calPoints(obs)->int:
result = None
L=[]
for i in range (len(ops)):
if ops[i]=='+':
try:
L.append(int(L[-1]) + int(L[-2]))
except:
print('For + there any 2 last number')
elif ops[i]=='D':
try:
L.append(int(L[-1])*2)
except:
print('for D there any last score')
elif ops[i]=='C':
try:
L.pop()
except:
print("For C there any previous score")
else:
try:
L.append(int(ops[i]))
except:
print('only print number')
result = 0
for i in range(len(L)):
result=result + L[i]
return result
if __name__=='__main__':
line=input()
ops=line.strip().split()
print(calPoints(ops))