raise
raise throws an error when your rule is broken. if age < 0: raise ValueError("age cannot be negative"). The caller can except it. Use a clear message. You can raise built-in types or a small custom class. This is how a function refuses bad input instead of returning a magic -1.
Tiny validation + raise ValueError is the fresher pattern. Don’t raise Exception("error") for everything — name the type.
Output — amount must be > 0. raise stops the function; except prints the message.
try: 10 / 0
│ ZeroDivisionError
▼
except → Cannot divide
│
▼
finallyif age < 0: raise ValueError(...).