<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_public_ip(addresses, version=4):
 """Return either the devices public IPv4 or IPv6 address. """

        for addr in addresses:
            if addr['public'] and addr['address_family'] == version:
                return addr.get('address')
        return None