Difference between "or" and bitwise operator in Python -


this question has answer here:

i new python programming, , ran problem.

while(true): paneltype = input("enter type of panel[a, b, c, d]: ") if(paneltype.lower() != "a"     | paneltype.lower() != "b"     | paneltype.lower() != "c"     | paneltype.lower() != "d"):     logger.error("not valid input. try again") else:     break 

when use bitwise operator error: unsupported operand type(s) |: 'str' , 'str'. however, once changed or operator, worked well.

could explain why occurred?

thanks

!= has lower precedence | tried calculating "a" | paneltype.lower() makes no sense.

| operator meant numbers, similar * or +, makes sense you'd calculate before making comparisons such > or !=. want or in case, has lower precedence.

better yet:

if paneltype.lower() in ('a', 'b', 'c', 'd'): 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -