Testing for Null?
alexnbryan at gmail.com
Sun Jun 29 01:05:24 CEST 2008
I am having a problem with a list value that is empty. I have a list of
definitions called mainList. the 5th value in the list doesn't have anything
in it. In this case, the values are definitions; also, in this case just the
word cheese is defined. Here is my output to the console:
5. a sprawling,weedy plant having small lavender or white flowers and
round, flat, segmented fruits thought to resemble little wheels of cheese.
7. an ingot or billet made into a convex, circular form by blows at the
I've made it so where the numbers, the period, and two spaces follow that,
then the definition. However, as you can see in 6, there is nothing. Here is
the code to print all this:
for x in mainList:
if mainList[n] == "":
print "Error on this definition"
print str(n+1)+". "+str(mainList[n])
Now the two "" is where I need to figure out if it is empty. What is up
right now doesn't work; or at least doesn't give the desired result. So I
need to know how to write the if statement to make it work. This should be
simple, but I just don't know how to do it, never had this problem before.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list