Questiion on list

Roman Yakovenko romany at actimize.com
Thu Jun 27 01:54:22 EDT 2002


import string
lst = ['a','b','c', 'a']
mapCount = {}

for word in lst:
    if not mapCount.has_key(string.lower(word)):
        mapCount[string.lower(word)] = 0
    mapCount[string.lower(word)] += 1
    
print mapCount

-----Original Message-----
From: SiverFish [mailto:occeanlinux at linuxmail.org]
Sent: Thursday, June 27, 2002 4:36 PM
To: python-list at python.org
Subject: Questiion on list


I got the list of words now i want to calculate how many word in that
list which is the same word (insensitive case),can anyone show me how to do
it for example ls = ['abc','cd','abc','adf',abc','dwc','cd']
it will show abc = 3 ,cd = 2, adf = 1, dwc=1
-- 
http://mail.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list