diff --git a/main.py b/main.py index 13248b6b4e71c2ffe8d3287fa7b2227ca3e65fa4..e2772495e517feaa2f137960afaf9b4555a31c84 100644 --- a/main.py +++ b/main.py @@ -7,31 +7,38 @@ from power import power def main(): while True: - print('Insert your first number: ', end='') - a = int(input()) - - print('Insert your second number: ', end='') - b = int(input()) - - print('Insert your operator (add/substract/division/multiplication/power): ', end='') - operator = input() - - if operator == 'add': - answer = addition(a,b) - - elif operator == 'substract': - answer = subtract(a,b) - - elif operator == 'division': - answer = division(a,b) - - elif operator == 'multiplication': - answer = multiplication(a,b) - - elif operator == 'power': - answer = power(a,b) - - print('The answer is', answer) + try: + print('Insert your first number: ', end='') + a = int(input()) + + print('Insert your second number: ', end='') + b = int(input()) + + print('Insert your operator (add/substract/division/multiplication/power): ', end='') + operator = input() + + if operator == 'add': + answer = addition(a,b) + + elif operator == 'substract': + answer = subtract(a,b) + + elif operator == 'division': + answer = division(a,b) + + elif operator == 'multiplication': + answer = multiplication(a,b) + + elif operator == 'power': + answer = power(a,b) + + else: + print('Incorrect operator') + continue + + print('The answer is', answer) + except Exception as error: + print(error) if __name__ == '__main__': main()