value exists (newbie question)

eldorado eldorado at
Tue Sep 19 21:06:40 CEST 2006


I am trying to parse some files so that if a postal code exists, but is 
longer than five digits it will return me only the first five digits:
for insDict in insureDict:
 	insDict['postalcode'] = insDict.get('postalcode')[:5]
This works, except for when I get a blank postalcode.  In which case I get 
the following error.
ERR exceptions.TypeError: iteration over non-sequence

What I would like to do is to check to make sure a value exists.  I just 
cannot seem to find the syntax to do that.  (not asking anyone to write my 
code, just looking for a pointer)


Randomly generated signature --
In God I Trust -- on all others I use dsniff, ettercap and lczroex

More information about the Python-list mailing list