Advertisement
Kamend1

Untitled

Aug 1st, 2023
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. def evaluate_expression(expression):
  2. if expression[0] == 'f':
  3. return expression[-1]
  4. if len(expression) == 5:
  5. if expression[0] == 't':
  6. return expression[2]
  7.  
  8. shorter_expression = expression[2:-2]
  9. return evaluate_expression(shorter_expression)
  10.  
  11.  
  12.  
  13. input_str = input()
  14. expression = input_str.replace(" ", "")
  15. result = evaluate_expression(expression)
  16. print(result)
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement