-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
  • 5,830
  • 9
  • 23
  • 39
Stacey
  • 4,327
  • 15
  • 47
  • 83
  • `&` 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
  • 7,711
  • 5
  • 33
  • 48
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: