I wish to make sure items in a list don't have duplicate elements not present in inputted word
<p>Right, so I need to make sure that each item in a list when compared to an inputted word don't contain duplicate elements that are not present in the inputted word. It's a bit difficult to explain so I'll just show what I've got so far:</p>

<pre><code>listword = input("Inputted word: ")
listcomparison = ["su", "pici", "nope", "pics", "susu", "poici","pic","pooici"]

for line in listcomparison:
word = list(listword)
while len(word) &gt;10:
    word = input("Inputted word needs to be less than or 10 letters long: ")
else:
    imp_letter = word[4]
    wordcount = len(line)

    if wordcount &gt;= 4:
        chars = list(line)


        if imp_letter in line and all(char in word for char in chars):
            print(line)           
</code></pre>

<p>I didn't mention it at the beginning, but the "imp_word" in the code is there because one requirement in the exercise is that the 5th letter in the inputted word must be present for all words in the list. </p>

<p>The problem with this is that when I run this program, using the inputted word "suspicion" for example, it will return "pici
pics
poici
pooici". The problem then is that words like pooici (well, "words") that have duplicate elements (pooici for example has two O) not present in the inputted word are showing up, when I'm supposed to make it so they... don't. BASICALLY, the inputted word is the allowed alphapet, and the quantity of each character is all that's allowed.</p>

<p>I know I SUCK at explaining this stuff, but I've been looking for a solution for almost a whole day now. Help a newbie out? </p>

<p>Use <a href="https://docs.python.org/3.5/library/collections.html#collections.Counter" rel="nofollow"><code>collections.Counter</code></a>.</p>

<p>Here are some examples of the <code>collections.Counter</code> in action:</p>

<pre><code>&gt;&gt;&gt; Counter("read")
Counter({'a': 1, 'r': 1, 'e': 1, 'd': 1})
&gt;&gt;&gt; Counter("dad") - Counter("read") # two "d" in "dad" minus one "d" in "read" leaves one "d"
Counter({'d': 1})
&gt;&gt;&gt; Counter("ad") - Counter("read") # letters "a" and "d" are in "read"
Counter()
&gt;&gt;&gt; bool(Counter()) # an empty Counter evaluates to False
False
</code></pre>

<p>Here's how to code a solution to your problem:</p>

<pre><code>words = ["su", "pici", "nope", "pics", "susu", "poici","pic","pooici"]
letter_counts = Counter("suspicion")
found_words = [word for word in words if not Counter(word) - letter_counts]
</code></pre>

<p><code>found_words</code> contains</p>

<pre><code>['su', 'pici', 'pics', 'poici', 'pic']
</code></pre>

python list python-3.x for-loop while-loop