What is vertical bar in Python bitwise assignment operator?


Vertical bar (|) stands for bitwise or operator. In case of two integer objects, it returns bitwise OR operation of two

>>> a=4
>>> bin(a)
'0b100'
>>> b=5
>>> bin(b)
'0b101'
>>> a|b
5
>>> c=a|b
>>> bin(c)
'0b101'

Updated on: 02-Mar-2020

917 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements