calculator.py
@@ -1,8 +1,8 @@ | |||
1 | 1 | while True: | |
2 | 2 | try: | |
3 | - | opr = input("calculator> ") | |
4 | - | exec(f'ans = {opr}') | |
5 | - | print(ans) | |
3 | + | print(eval(input("calculator> "))) | |
4 | + | except Exception as e: | |
5 | + | print(e) | |
6 | 6 | except KeyboardInterrupt: | |
7 | 7 | print() | |
8 | - | quit() | |
8 | + | quit() |
Новее
Позже