[Tutor] testing for "None"
Remco Gerlich
scarblac@pino.selwerd.nl
Thu, 19 Apr 2001 14:35:00 +0200
On 0, Sharriff Aina <NHYTRO@compuserve.com> wrote:
> Hi guys!
>
> ## code start ##
> templinks = [("aa,None,cc,dd")] # from databse
> links = string.split(templinks[0],",")
> for x in links:
> if x != None:
> counter = counter + 1
> print "<td>%d. </td>" %(counter)
> print "<td>",
> print x
> print """
> </td>
> <td><input type="button" onclick="" value="edit"</td>
> </tr>
> <tr>
> """
> else:
> pass
> ## code end ##
>
> can someone tell me why this code fails? I´m trying to print values that
> are not " None"
None of the values are None, they're all strings - "aa", "None", "cc" and
"dd".
You should be testing for the string "None", not the object None
(if x != "None": ...).
--
Remco Gerlich