This line:
if j in list1:
list1.remove(j)
is your problem. Think about the first iteration of for word in str_list where word == 'ppl
going through the following code with that in mind:
for j in listi: #for every char in word, 'p', 'p', 'l'
if j in list1: 'True for all three
list1.remove(j) 'removes all three letters
else:
shouldAdd = False
this leaves you with list1 == ['a','e']. Your next iteration for word gives you word == 'al'. If we go through the above code again, you'll see that since there is no longer 'l' in list1, shouldAdd == False. Also, since a was in it, it now isn't and list1 == ['e']. You can see where this is going.
Using your code, you can fix this by moving list1 = list(str) to inside of your for word in str_list: loop so that it reinitializes the list every time. I am going to try to find a more pythonic way of doing the function and post it when I can.
EDIT:
Here is my way of doing this:
>>> def is_sub_anagram(s, sub):
s = list(s)
try:
for c in sub: s.remove(c)
except:
return False
return True
>>> def find_sub_anagram_in_wordlist(s, str_list):
return list(filter(lambda x: is_sub_anagram(s,x), str_list))
>>> find_sub_anagram_in_wordlist('apple',['app','ppl','ae','le'])
['app', 'ppl', 'ae', 'le']
>>> find_sub_anagram_in_wordlist('apple',['app','ppl','ae','le','lle'])
['app', 'ppl', 'ae', 'le']
listobject has no attributeclear. Can you show some code that actually works?