```
class Solution:
# @param n, an integer
# @return an integer
def hammingWeight(self, n):
return bin(n)[2:].zfill(32).count('1')
```

Here is my one- line solution to the above problem. LMK if I optimize this further somewhere.

edit:

Above was my first solution, I quickly realized that I dont have to make it a 32 bit integer . I got rid of the zfill , and my solution is down to 48 ms. My solution is now as below.

```
class Solution:
# @param n, an integer
# @return an integer
def hammingWeight(self, n):
return bin(n)[2:].count('1')
```