```
class Solution:
# @param {integer} n
# @return {boolean}
def isPowerOfTwo(self, n):
return any(n == 2 ** i for i in range(32))
```

or

```
class Solution:
# @param {integer} n
# @return {boolean}
def isPowerOfTwo(self, n):
return any(n == 1 << i for i in range(32))
```

or bit hack

```
class Solution:
# @param {integer} n
# @return {boolean}
def isPowerOfTwo(self, n):
return n > 0 and n & (n - 1) == 0
```