a cleaner test would be:

```
if isinstance(n, (float, int)):
```