-4

I want to find the big number. But after compile, it showing b value. But c is the big number of all those.

a= 21
b=22
c= 23

if a>(b&c):
    print(a)
elif b>(c&a):
    print(b)
else :
    print(c)
Tagore
  • 1
  • 1
  • 1
    why do you need the bitwise and in there? – rv.kvetch Sep 22 '21 at 03:40
  • 2
    Duplicate: [How to test multiple variables against a single value?](https://stackoverflow.com/questions/15112125/how-to-test-multiple-variables-against-a-single-value) – esqew Sep 22 '21 at 03:41
  • Please also brush up on the difference between a [bitwise AND `&`](https://wiki.python.org/moin/BitwiseOperators) and [the `and` keyword](https://docs.python.org/3/reference/expressions.html#boolean-operations). – esqew Sep 22 '21 at 03:43

2 Answers2

2

What you really want is just max(a, b, c)

Frank Yellin
  • 9,127
  • 1
  • 12
  • 22
0

You have to use logical "and" instead of bit wise &. You can use like below using logical and operator.

a= 21
b=22 
c= 23 
if (a>b) and (a>c):
   print(a) 
elif (b>c) and (b>a): 
   print(b) 
else: 
   print(c)