0

I would like to set a limit number, so when somebody types some big number like 9999 or -9999 it displays an error message. Also I feel like the else is useless in this code and I can't come up with an idea on how to use it.

n1=int(input("\nIngrese el primer número entero:  "))
n2=int(input("\nIngrese el segundo número entero: "))
n3=int(input("\nIngrese el tercero número entero: "))

if n1>n2 and n1>n3:
    print(f"\nEl mayor número de los 3 ingresados es: {n1}")
elif n2>n1 and n2>n3:
    print(f"\nEl mayor número de los 3 ingresados es: {n2}")
elif n3>n1 and n3>n2:
    print(f"\nEl mayor número de los 3 ingresados es: {n3}")
elif int(n1==n2) or int(n1==n3) or int(n2==n1) or int(n2==n3):
    print("\nPor favor, ingrese 3 números diferentes.")
else:
    print("\nERROR:Por favor, ingrese 3 números diferentes y que sean enteros.")
martineau
  • 119,623
  • 25
  • 170
  • 301
  • 1
    Have you tried putting each input into a while loop. If they enter a good number it will break else it will keep asking them? –  Aug 08 '20 at 23:24
  • Maybe place this if statement inside another one, so if n1,n2 and n3 are inside range from one to another number it runs the function, else it doesn't but display error message – Никола Тошић Aug 08 '20 at 23:36

0 Answers0