code: def get_public_ip(addresses, version=4):
          
          for addr in addresses:
              if addr['public'] and addr['address_family'] == version:
                  return addr.get('address')
          return None
docs: Return either the devices public IPv4 or IPv6 address.