Why does this not work?

Byron Morgan lazypointer at yahoo.com
Tue Jan 7 03:19:51 EST 2003


try

if a in (0,1) and b in (0,1):


"Tetsuo" <member16943 at dbforums.com> wrote in message
news:2355358.1041918087 at dbforums.com...
>
> You know you suck if the calculator you are making isn't required to add
> 2 and 2, and you still can't get it to work.
>
> s = 0
> c = 0
> def halfadder(a, b):
>     if a and b in (0, 1):
>         if a and b == 1:
>             s = 1
>             c = 0
>             print s, c
>         elif a and b == 0:
>             s = 0
>             c = 0
>             print s, c
>         else:
>             s = 0
>             c = 1
>             print s, c
>     else:
>         print "Number out of range! Enter 0 or 1, please."
>
> halfadder(1,1)
> halfadder(1,0)
> halfadder(0,1)
> halfadder(0,0)
>
> --
> Posted via http://dbforums.com






More information about the Python-list mailing list