-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
  • 77,035
  • 9
  • 115
  • 152
Daniele Caliari
  • 138
  • 1
  • 10