**right code:**

```
class Solution(object):
def countBits(self, num):
lst = [0] * (num + 1)
milestone = 0
nextMilestone = 2
for i in range(1, num + 1):
if i == nextMilestone:
milestone = nextMilestone
nextMilestone = nextMilestone * 2
lst[i] = lst[i - milestone] + 1
return lst
```

the code above is my right solution , and I think it's perfect. But the problem is when I replace the '==' to 'is' , I got a "Output Limit Exceeded"! please tell me why T_T

**wrong code:**

```
class Solution(object):
def countBits(self, num):
lst = [0] * (num + 1)
milestone = 0
nextMilestone = 2
for i in range(1, num + 1):
if i is nextMilestone:
milestone = nextMilestone
nextMilestone = nextMilestone * 2
lst[i] = lst[i - milestone] + 1
return lst
```