}
-def convert_ip(ip : str):
+def convert_ip(ip : str) -> str:
"""
- Convert a hex string representing an IP address to conventional
- human-readable form, ie. dotted-quad decimal for IPv4, and
- 8 colon-separated hex shorts for IPv6.
+ Convert a hex string representing an IP address to
+ human-readable form.
+
+ Parameters
+ ----------
+
+ ip : str
+ The hexadecimal representation of either an IPv4 or an IPv6
+ address.
+
+ Returns
+ -------
+
+ The usual decimal dotted-quad representation is returned for an
+ IPv4 address. IPv6 addresses are returned almost as-is, but with
+ colons inserted in the appropriate places, between every four
+ characters.
Examples
--------
'127.0.0.1'
>>> convert_ip("00000000000000000000ffff7f000001")
'0000:0000:0000:0000:0000:ffff:7f00:0001'
-
"""
if len(ip) == 8:
# IPv4, eg. "7f000001" -> "7f 00 00 01" -> "127.0.0.1"