How to handle blank form value in python
<p>I have 2 form fields in my html code, which hits to python script. Everything works perfectly if i provide both input in form. But in my case, 2nd field is optional. I am getting blank result when i submit form with 1st field only. How to handle my code to run even when 2nd field is blank/null</p>

<p>python code:</p>

<pre><code>import cgi
form = cgi.FieldStorage()
first=form["firstSix"].value
last=form["lastFour"].value
</code></pre>

<pre><code>import cgi
form = cgi.FieldStorage()
first=form["firstSix"].value

if form["lastFour"]:
    last=form["lastFour"].value
else:
    form["lastFour"] = None
</code></pre>

python