Hello when I try to make a basic input panel I encounter with that error.
TypeError: unsupported operand type(s) for |: ‘str’ and ‘str’
ip = str(input(">>> "))
if ip == "0" | ip == "00":
pass
elif ip == "1" | ip == "01":
send()
elif ip == "2" | ip == "02":
st()
elif ip == "3" | ip == "03":
fst()
elif ip == "4" | ip == "04":
res
Just WHY???
>Solution :
| is the bitwise-or operator. From Operator precedence, | binds tighter than ==, so
ip == "0" | ip == "00"
could be expressed as
ip == ("0" | ip) == "00"
str doesn’t support bitwise-or, so the "0" | ip fails. You wanted logical or. Since or has lower precedence than ==, this works
ip == "0" or ip == "00"