MarkokraM
MarkokraM

Reputation: 990

Smaller and greater comparison in Python 3

I see this code used on Python 2 library:

if a <> '0'

but in Python 3 it throws an error:

SyntaxError: invalid syntax

Now I'm not totally sure if the comparison is similar to:

if a < '0' and a > '0'

Or does it mean something else?

Upvotes: 0

Views: 63

Answers (1)

Deepak Tripathi
Deepak Tripathi

Reputation: 630

If values of two operands are not equal, then condition becomes true. for example (1 <> 2) is true. This is similar to != operator.

in your case use if a != '0'

Upvotes: 1

Related Questions