| Defining a function runs it | Body runs only when called |
| Local variables survive the function | They vanish on return; assigning inside a function makes a local unless declared global |
A missing return is harmless | Any path without return gives None |
a = b is like algebra equality | It copies a value at one moment; 7 = a is illegal |
x == 0.1 + 0.2 is safe with floats | Compare with $ |
| You can edit a string/tuple character | Immutable: build a new one |
| String comparison ignores case | It is case-sensitive: all uppercase letters come before lowercase |
t = t.sort() sorts t | sort works in place and returns None; now t is None |
b = a copies a list | It aliases; use a[:] or copy (deep copy for nested objects) |
in checks dict values | It checks keys only |
(a) is a tuple | Needs a comma: (a,) |
Mode 'w' appends | It erases old contents |
== compares object data | Default checks identity; define __eq__ (and __lt__ for <) |
Child __init__ runs parent's | Call the parent's __init__ explicitly |
| The error is on the flagged line | Syntax errors are often earlier |
| Passing tests means no bugs | Tests show bugs exist, not that none exist; test edge cases like '' |
zip checks lengths | It stops at the shortest sequence |