I am a bit new in python, and have just learned about the try except else and finally statement.
try:
x=int(input("enter a number:")
except:
print("you entered a wrong type of input, make sure to enter an integer value")
else:
print(f"running in else : {x}")
finally:
print(f"finally : {x+2}")
This will cause another exception in finally block NameError name 'x' is not defined
if I enter anything other than an integer value in my input statement
Does it mean we have to put all that is related to x in the else block and all that have nothing to do with x, in the finally block?
My actual script is very long but I'm trying to understand this concept from a smaller example
Is this a right intuition?
Please suggest me if otherwise