Hi,
I have a thousands of IP addresses, repeating randomly in my database and I wish to print each IP address along with the number of times they are repeated.
For example,
162.10.2.1
162.10.2.1
162.10.2.1
192.34.1.10
172.11.2.9
192.34.1.10
192.34.1.10
Output:
162.10.2.1 - 3
192.34.1.10 - 3
172.11.2.9 - 1
I have used Counter() to do this manually by listing them individually and then using Counter(list). As there are thousands of IP addresses, it is impossible to list them out manually in the program. Is there any way where I can get the output with a for loop or anything else?