Veuillez jeter un coup d'œil à ce programme.Python append remplace la liste existante par None
La fonction d'ajout remplace la liste par None. L'erreur est joint ci-dessous
class Solution(object):
def isIsomorphic(self, a, b):
ad = {}
bd = {}
if len(a) != len(b):
return False
for i in range(len(a)):
if a[i] in ad:
ad[a[i]] = ad[a[i]].append(i)
else:
ad[a[i]] = [i]
if b[i] in bd:
bd[b[i]] = bd[b[i]].append(i)
else:
bd[b[i]] = [i]
ret = True
for j,k in zip(ad.values(), bd.values()):
if j != k:
return False
return ret
sol = Solution()
print sol.isIsomorphic("ccc", "aab")
erreur
ad[a[i]] = ad[a[i]].append(i)
AttributeError: 'NoneType' object has no attribute 'append'