Each separate statement is true, but why is the combination of the two with "and" false? codes
Each separate statement is true, but why is the combination of the two with "and" false? codes
In python and is a logical AND that returns True if both the operands are true whereas ‘&’ is a bitwise operator. I think you are trying to to something like this.
if (other_list[0] == 0 and rand_vec[0] == 1):
# Do something
Many thanks to Pw Wolf and all others! Now I understand it.
Original code:
if (other_list[0] == 0 & rand_vec[0] == 1):
# do something
Improved code:
if (other_list[0] == 0 and rand_vec[0] == 1):
# do something