What is the expected behavior for the following code?
Converting '2A' with int() raises ValueError because it is not a valid integer literal. The matching except ValueError block assigns 2 to n, so print(n) outputs 2.
'2A'
int()
ValueError
except ValueError
2
n
print(n)
Community Discussion