try:
x = float(input("Your number: "))
inverse = 1.0 / x
finally:
print("There may or may not have been an exception.")
print("The inverse: ", inverse)
Ausgabe des vorigen Skriptes:
bernd@venus:~/tmp$ python finally.py
Your number: 34
There may or may not have been an exception.
The inverse: 0.0294117647059
bernd@venus:~/tmp$ python finally.py
Your number: Python
There may or may not have been an exception.
Traceback (most recent call last):
File "finally.py", line 3, in <module>
x = float(raw_input("Your number: "))
ValueError: invalid literal for float(): Python
bernd@venus:~/tmp$