How to convert an input to string
<pre><code>while n == 1:
    w = inputs.append(input('Enter the product code: ')) 
    with open('items.txt') as f: 
        found = False
        for line in f:
            if w in line:
</code></pre>

<p>So this is the part of the code with the issue. After the last line a bunch of stuff happens which is irrelevant to the question. When i run it, i get the error:<br>
    if w in line:<br>
TypeError: 'in ' requires string as left operand, not NoneType</p>

<p>I know it's because i need to convert w to a string somehow but i don't know what to do. Any help is appreciated.</p>

<p><a href="https://docs.python.org/3/library/functions.html#input" rel="nofollow"><code>input()</code></a> already returns a string, so there is no need to convert it.</p>

<p>You have this:</p>

<pre><code>w = inputs.append(input('Enter the product code: ')) 
</code></pre>

<p>You should be doing this in two steps, since you are assigning <code>w</code> to the return value of <code>append()</code>, rather than the return value of <code>input()</code> in this case. <code>append()</code> will always return <code>None</code> regardless of the user input, so <code>w</code> in your program will be assigned to <code>None</code>. Instead, try:</p>

<pre><code>w = input('Enter the product code: ')
inputs.append(w)
</code></pre>

python