class Solution(object):
def hammingWeight(self, n):
weight = 0
if n == 0:
return n
while n >= 1:
remainder = n % 2
n = n / 2
if remainder != 0:
weight += 1
return weight

class Solution(object):
def hammingWeight(self, n):
"""
:type n: int
:rtype: int
"""
if n==0 or n==1:
return n
r=[]
while(n>0):
r.append(n%2)
n/=2
return sum(r)