What Does & Mean in Python [Duplicate]
I Came Across the Following Code Numdigits = Len(Cardnumber) Oddeven = Numdigits & 1 What Exactly Is Going on Here? I'm Not Sure What the "&" Is Doing. 2 5...
I came across the following code
numdigits = len(cardNumber)
oddeven = numdigits & 1
what exactly is going on here? I'm not sure what the "&" is doing.
5 Answers
Must Read
Answer
The & symbol is a bitwise AND operator. Used with 1, it basically masks the value to extract the lowest bit, or in other words will tell you if the value is even or odd.