Searching Elements of a List
<p>I am trying to search a array of previous usernames used in a game, for the username currently used by the gamer (allowing all the previous game scores under the username to be displayed). This list has been imported from an external text file.</p>

<pre><code>for x in range(0, len(lis)):
    if username == lis[x]:
        print "yes"
    print lis[x]
</code></pre>

<p>Here for example, the username could be "Jack". Even though multiple elements in lis have the value "Jack" (verified by printing all the values of the list through 'print lis[x]'), "yes" is never printed to show this.</p>

<p>What's going wrong?</p>

<p>I'm not sure if it is what you meant but at least this prints yes:</p>

<pre><code>lis = ["Jack","Rose", "Joe", "Franz"]
username = "Joe"
for x in range(0, len(lis)):
if username == lis[x]:
    print ("yes")
</code></pre>

python list