def count_chars(s):
'''Return a dict that contains each character in str s as a key. The
value associated with each key is the number of times that character
occurs in s.'''
d = {}
for ch in s:
if ch in d:
d[ch] += 1
else:
d[ch] = 1
return d
コードの3行目、「ifchind」が表示されません。まだ辞書にエントリがないのに、なぜそのキャラクターが辞書に載っているのですか?
また、d [ch] + = 1が何を意味するのか、そしてなぜelseステートメントがあるのかわかりません。誰か助けてくれませんか?