with open(file) as file:
    for ip in file:
        ip_data = re.findall(
            '(?:[\\d]{1,3})\\.(?:[\\d]{1,3})\\.(?:[\\d]{1,3})\\.(?:[\\d]{1,3})'
            , ip)
for i in ip_data:
    ips.append(i)
for ipaddr in ips:
    if ipaddr in occurence:
        occurence[ipaddr] = occurence[ipaddr] + 1
else:
    occurence[ipaddr] = 1
for key, value in occurence.items():
    print(key, value)
return None
print(grab_ip('data'))
Получение IP-адресов из файла и подсчет вхождений