On Fri, May 20, 2011 at 9:37 PM, ErichCart ErichCart <erichc...@gmail.com> wrote: > For example, I was writing a program to detect whether two strings are > anagrams of each other. I had to write it like this: > > def isAnagram(w1, w2): > w2=list(w2) > for c in w1: > if c not in w2: > return False > else: > w2.remove(c) > return True
You may find it helpful to simply sort the lists, keeping them as lists. If they're anagrams of each other, their sorted versions will be equal. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list