I was just trying to understand Try and except statements better.I am stuck. So I was hoping if you guys could clarify. This program purely for learning.
Appreciate your input.
while True:
    x=int(input('enter no.->'))
    try:
        x/2
    except ValueError:
        print('try again')
    else:
        if (x/2)==1:
            break
print('program end')
So i wrote this program with the intention-
- loop if x is a number
- if it is not. then 'except' comes into play and starts again
- if quotient is 1. STOP.
Even if I change it to
    x=input('enter no.->')
    try:
        int(x)/2
'except' works but I get 'unsupported operand type(s)' if i put in a number.
 
     
     
    