$ ./guess_the_languageProblem Solving — fill the blank
Problem Solving — fill the blank · medium · #302

What goes in the blank?

# number of 1 bits: 13 (0b1101) -> 3
ones = n.____()

Answer: bit_count (also accepted: bit_count, bit_count())

int.bit_count (Python 3.10+) returns the population count, the number of set bits.
Play Problem Solving ▸