dict = {}
raw_input('Please enter a string :')
letter = raw_input()
for letter in raw_input:
if letter not in dict.keys():
dict[letter] = 1
else:
dict[letter] += 1
print dict
My error:
line 9, in <module>
TypeError: 'builtin_function_or_method' object is not iterable
worked for me when i changed for letter in raw_input:
to for letter in raw_input():
and the input was "question" and output was "{'e': 1, 'i': 1, 'o': 1, 'n': 1, 'q': 1, 's': 1, 'u': 1, 't': 1}" , and also i think you can change the part of code inside the for loop to dict[letter] = dict.get(letter,0) + 1
if you like.