   how to search a list for specific characters?
  I want to use count(x) to see how many times a letter occurs in a list I have.For example the list might bestuff = ['orange','apple','pear']And I want to know how many A's are in the list. any idea how I might go about doing that?If I use stuff.count('a') it doesn't work (I guess it has to match the entire string). Anyone know how to count how many times a single letter occurs in a list of strings? I'm using PythonThanks in advance,[edited by - xegoth on February 15, 2004 11:13:51 PM]
  What language is this? ;  You might want to specify what language you''re using.   ______________________________________________________________The Phoenix shall arise from the ashes...   ThunderHawk -- ¦þMySite______________________________________________________________ ;  lol, oh yeah. Python. ;def countCharacter( ch, L = [] ):   return sum( map(lambda x: x.count(ch), L) ) ;  Game of the day: eliminate the lambda def countCharacter( ch, L = [] ): return sum( map( string.count, L, ch*len(L) ) )   edit - fixed“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”    — Brian W. Kernighan (C programming language co-inventor) [edited by - Fruny on February 16, 2004 3:50:38 AM];  That would be string.count, not list.count. ;>>> stuff = [''orange'',''apple'',''pear'']>>> ''''.join(stuff).count(''a'')3>>> ''''.join(stuff).count(''n'')1>>> ''''.join(stuff).count(''z'')0 [ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost  Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]    ;  Kylotan, you''re evil! I need to work more closely with you... 