So the task is rather simple. Read in a string and store each character and its frequency in a dictionary then return the dictionary. I did it rather easily with a for loop.
def getInputFreq():
txt = input('Enter a string value: ')
d = dict()
for c in txt:
d[c] = d.get(c,0) + 1
return d
The issue is that I need to rewrite this statement using a map and lambda. I've tried a few things, early attempts returned empty dictionaries ( code has been lost in the attempts ).
My latest attempt was ( in place of the for loop in above )
d = map((lambda x: (d.get(x,0)+1)),txt)
which returns a map object address.
Any suggestions?