Нема описа

tt.py 418B

123456789101112131415161718192021222324252627
  1. def toList(s):
  2. L = []
  3. for i in s:
  4. if i != '\n':
  5. L.append(i)
  6. return L
  7. def f(i,s,S = None):
  8. if not S:
  9. S = []
  10. if i == len(s):
  11. return S[0]
  12. a = s[i]
  13. if a.isdigit():
  14. S.append(a)
  15. return f(i+1,s,S)
  16. else:
  17. c = S.pop()
  18. d = S.pop()
  19. e = '%s%s%s'%(c,a,d)
  20. S.append(eval(e))
  21. return f(i+1,s,S)