class Solution(object): def hammingWeight(self, n): """ :type n: int :rtype: int """ # print(n, bin(n), str(bin(n))) binary_string = str(bin(n)) return binary_string.count("1")