-2

what does the expression "~" mean?

enter image description here

Jens
  • 9
  • 4

1 Answers1

0

from the doc: https://docs.python.org/3/reference/expressions.html#unary-arithmetic-and-bitwise-operations

The unary ~ (invert) operator yields the bitwise inversion of its integer argument. The bitwise inversion of x is defined as -(x+1). It only applies to integral numbers or to custom objects that override the __invert__() special method.

juanpa.arrivillaga
  • 88,713
  • 10
  • 131
  • 172
Daniele Caliari
  • 158
  • 1
  • 11