How to Detect an Empty Value
<p>I'm currently making a Python script for account creation. My script is as follows:</p>

<pre><code>import csv
nms = []
with open('nms.txt', newline='') as inputfile:
    for row in csv.reader(inputfile):
        nms.append(row)
counter = 0        
## End of tings
while True:        
    print ("Please enter your user name. This must be unique.")
    usernm = input ("")
    while True:
        if nms[1][counter] != (""):
            print (".")
        else:
            break
        if usernm == nms[1][counter]:
            print ("Unfortunately this user name is in use. Please try a different user name.")


        counter = counter + 1

print ("end")
</code></pre>

<p>The issue is that with the way I've made my script, where I've tried to stop the program checking if the username is equal to a blank value, it of course errors, is there a better method of detecting a null value? So that when it actually see's one, it will break out of the while loop? The rest of my program thus far seems to work fine.</p>

<p>I'm not sure I see the need for the counter variable, but you can check if an item exists in an iterable object with <code>in</code></p>

<pre><code>if usernm in nms:
    # user already exists 
</code></pre>

<blockquote>
  <p>I've tried to stop the program checking if the username is equal to a blank value</p>
</blockquote>

<p>It looks like you checked if the second value of <code>nms</code> at the character of the index <code>counter</code> is an empty string. You didn't check the username that was input at all. </p>

<pre><code>if usernm.trim() == "":
    # username is blank 
</code></pre>

python input value