key parameter defines sorting order, in this case we take first part before ':' and make it integer for comparison in nameless lambda function. If you feel unconfortable with lambda you can also define the function separately with name with def and give it as key parameter.
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?
Please do not hijack an existing thread, start your own thread with the appropriate title.