I think there are 2 steps.

Step1: find the right digits.

Step2: determine whether those digits are in the right place or not.

```
class Solution(object):
def getHint(self, s, g):
"""
:type secret: str
:type guess: str
:rtype: str
"""
counts = [0]*10
cows = bulls = 0
for i in range (0, len(s)):
if s[i]==g[i]: bulls +=1
else:
index = int(s[i])
counts[index] +=1
if counts[index] <=0: cows+=1
index = int(g[i])
counts[index] -=1
if counts[index] >=0: cows+=1
return str(bulls)+"A"+str(cows)+"B"
```