while True:
try:
a=int(input())
except:
print ('invalid value')
else:
break
how to put second input here ?
this code is small and does the two checks I wanted but does not return to the input
while True:
try:
print(int(input("Enter an integer"))/int(input("Enter another integer")))
except:
print("Either you entered a non-numeric value or tried to divide by zero")
else:
break
so is better but I have no values for variables a and b
try:
a=int(input())
except:
print ('invalid value')
else:
break
how to put second input here ?
(May-06-2020, 10:31 PM)jefsummers Wrote: The length of code was trying to explain more to you. If brevity is important
try: print(int(input("Enter an integer"))/int(input("Enter another integer"))) except: print("Either you entered a non-numeric value or tried to divide by zero")
this code is small and does the two checks I wanted but does not return to the input
while True:
try:
print(int(input("Enter an integer"))/int(input("Enter another integer")))
except:
print("Either you entered a non-numeric value or tried to divide by zero")
else:
break
so is better but I have no values for variables a and b