Ad
Code
Diff
  • def calc(string):
        try: 
            return int(eval(string))
        except (NameError, SyntaxError, TypeError, ValueError, ZeroDivisionError) as e:
            print(e)
            return 'Invalid Input'
    
    • def calc(string):
    • try: return int(eval(string))
    • try:
    • return int(eval(string))
    • except (NameError, SyntaxError, TypeError, ValueError, ZeroDivisionError) as e:
    • print(e)
    • return 'Invalid Input'