from collections import defaultdict
my_word="apple"
d = defaultdict(list)
for a,b in zip(my_word,my_word[1:]):
d[a].append(b)
maybe?… collections.Counter
might be usefull as well
0
solved Creating a dictionary based on a word [closed]
from collections import defaultdict
my_word="apple"
d = defaultdict(list)
for a,b in zip(my_word,my_word[1:]):
d[a].append(b)
maybe?… collections.Counter
might be usefull as well
0
solved Creating a dictionary based on a word [closed]