What does & mean in python

前端 未结 5 2542
长情又很酷
长情又很酷 2020-11-28 08:20

Hi I came across the following code

numdigits = len(cardNumber)
oddeven = numdigits & 1

what exactly is going on here? I\'m not sure wh

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-28 09:01

    & is a bitwise and, which is an efficient way to do bit-level calculations. It is taking numdigits and and-ing it with 1, bit-by-bit.

提交回复
热议问题