<p><br>lstOne = [ 'A', 'B', 'C', 'C' ]</p>
<div>dct = {}<br>for item in lstOne:<br>    if dct.has_key(item):<br>        dct[item] += 1<br>    else: dct[item] = 1<br></div>
<div> </div>
<div class="gmail_quote">On Thu, Mar 27, 2008 at 10:51 PM, Kelly Greer <<a href="mailto:kellygreer1@yahoo.com">kellygreer1@yahoo.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">I'm in Python 2.4.4<br><br>And it works for me in the Python Shell like you just<br>did. Let me try another thing or two. I can't<br>
reproduce the unhashable error now. :(<br><br>Can you help me with one more thing?<br>If I have<br>lstOne = [ 'A', 'B', 'C', 'C' ]<br><br># what is the easiest way to get<br># back a dictionary like this:<br>
dct = { 'A': 1, 'B': 1, 'C': 2 }<br># in other words counting the times a letter appears<br>in the list.<br><br>Thanks,<br>Kelly<br>
<div>
<div></div>
<div class="Wj3C7c"><br><br>--- Furkan Kuru <<a href="mailto:furkankuru@gmail.com">furkankuru@gmail.com</a>> wrote:<br><br>> set(lstone)<br>> works fine in python 2.5.1<br>><br>> Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08)<br>
> [MSC v.1310 32 bit (Intel)]<br>> on<br>> win32<br>> Type "help", "copyright", "credits" or "license" for<br>> more information.<br>> >>> lstone = [ 1, 2, 3, 3, 4, 5, 5, 6 ]<br>
> >>> set(lstone)<br>> set([1, 2, 3, 4, 5, 6])<br>><br>><br>><br>> On 3/26/08, kellygreer1 <<a href="mailto:kellygreer1@yahoo.com">kellygreer1@yahoo.com</a>><br>> wrote:<br>> ><br>
> > What is the best way to filter a Python list to<br>> its unique members?<br>> > I tried some method using Set but got some<br>> "unhashable" error.<br>> ><br>> > lstone = [ 1, 2, 3, 3, 4, 5, 5, 6 ]<br>
> > # how do i reduce this to<br>> > lsttwo = [ 1, 2, 3, 4, 5, 6 ]<br>> ><br>> > Is there a page on this in the Python in a<br>> Nutshell or the Python<br>> > Cookbook?<br>> > Did I miss something?<br>
> ><br>> > Kelly Greer<br>> > <a href="mailto:kellygreer1@nospam.com">kellygreer1@nospam.com</a><br>> > change nospam to yahoo<br>> > --<br>> ><br>> <a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
> ><br>><br>><br>><br>> --<br>> Furkan Kuru<br>><br><br><br><br></div></div>
<div class="WgoR0d">     ____________________________________________________________________________________<br>Be a better friend, newshound, and<br>know-it-all with Yahoo! Mobile.  Try it now.  <a href="http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ" target="_blank">http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ</a><br>
</div></blockquote></div><br><br clear="all"><br>-- <br>Furkan Kuru