I'm trying to go through an array and delete the elements that aren't anagrams in python. Here is the code I wrote. My logic seems fine but I can't seem to get it.
b = ['cat', 'dog', 'god', 'star', 'lap', 'act']
array=[]
t=0
for i in b:
while t<len(b):
if ''.join(sorted(i))==''.join(sorted(b[t])):
array.append(i)
t+=1
print array
Just some minor tweaks to your existing code should work.