diff --git a/calculator.py b/calculator.py index cac6635..d0310d1 100644 --- a/calculator.py +++ b/calculator.py @@ -1,8 +1,12 @@ # Custom function to read the two numbers. def read_numbers(): - num1 = float(input('Enter first number: ')) - num2 = float(input('Enter second number: ')) - return num1, num2 + while True: + try: + num1 = float(input('Enter first number: ')) + num2 = float(input('Enter second number: ')) + return num1, num2 + except ValueError: + print("Error: Por favor, introduce solo numeros validos") # Simple menu. print('Welcome to the calculator!') @@ -45,4 +49,4 @@ def read_numbers(): elif choice == '5': break else: - print('Invalid Input') \ No newline at end of file + print('Invalid Input')