fork download
  1. import re
  2.  
  3. exp = None
  4. while True:
  5. exp = input('Введите выражение или введите \'exit\'\n')
  6. exp.replace(' ', '')
  7. check_exp = re.findall(r'^\d+[\+\-\\\*]{1}\d+$', exp)
  8. if check_exp:
  9. print(eval(check_exp[0]))
  10. elif exp == 'exit':
  11. break
  12. else:
  13. print('Данные некоректны')
  14. continue
  15.  
Runtime error #stdin #stdout #stderr 0.01s 28384KB
stdin
Standard input is empty
stdout
Введите выражение или введите 'exit'
stderr
Traceback (most recent call last):
  File "./prog.py", line 5, in <module>
EOFError: EOF when reading a line