Coming from Java and C based languages, this looks odd in Python. The x variable is defined in the try block but used outside of it.
I understand that python does not scope the try block though.
try:
x = 5
except Exception as e:
print(str(e))
print(f"x = {x}")
Is this considered to be good form in Python, or is it preferred to set, say, x = None beforehand? or some third option? Why?