-1

New to python, I cannot get the following simple compounded if statement to work

if A == B & C >= D & C <= E:

each of the sub statements works on there own but I can't seem to combine them together in one command.

Gaurav Dave
  • 6,838
  • 9
  • 25
  • 39
Stacey
  • 4,825
  • 17
  • 58
  • 99
  • `&` is a [binary bitwise operator](https://docs.python.org/3/reference/expressions.html#binary-bitwise-operations), not the logical `and`. –  Apr 27 '16 at 12:25

2 Answers2

3
if A == B and C >= D and C <= E:
Keiwan
  • 8,031
  • 5
  • 36
  • 49
0

& is a binary bitwise operator, not the boolean operator and you are looking for.

Do this:

if A == B and C >= D and C <= E: