Operators

>> — Right bit shift

For integers, shifts toward lower bit positions. For nonnegative count it equals floor division by 2**count, including negative inputs, so -3 >> 1 is -2 rather than -1. Python integers behave as if sign bits extend indefinitely. There is no separate unsigned right-shift operator. Negative counts raise ValueError. Custom implementations use __rshift__ and __rrshift__.

Formal Syntax & Structure

python syntaxpython
left >> right

Parameters & Attributes

NameTypeDescription
leftint or supporting objectInteger to shift or supporting object.
rightint or supporting objectNonnegative integer bit count for integer shifting.

Return Value

object

Result selected by the operand types and their operation implementations.

Working Example

Example Snippetpython
print(20 >> 2)print(-3 >> 1)print(1 >> 100)
Python Reference