#14814: Fix errror message creation in ipaddress.collapse_addresses
diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py
index 7df9f20..6763517 100644
--- a/Lib/ipaddress.py
+++ b/Lib/ipaddress.py
@@ -359,7 +359,7 @@
         else:
             if nets and nets[-1]._version != ip._version:
                 raise TypeError("%s and %s are not of the same version" % (
-                        str(ip), str(ips[-1])))
+                        str(ip), str(nets[-1])))
             nets.append(ip)
 
     # sort and dedup