First of all 172.31.xxx.xxx is still private address (range(16, 31) returns [16, 17, .., 30]). Second of all:
```
.. and 16 <= int(ip_parts[1]) <= 31
```