I am learning RxPY , so I need to write some code which can split each word by its first character. The results must look something like this:
{'a': ['a'], 't': ['the','the'], 'l': ['low','lazy']}
What I've tried.
from rx import Observable , Observer
list =['A', 'The', 'the', 'LAZY', 'Low']
o = Observable . from_ ( list )\
. filter (lambda i: i[0] == 'A' or 'Z' )\
words = o.map(lambda s: s.lower().split())
word_each = words.flat_map(lambda s: s)
ss = word_each.to_dict(lambda x: x[:1], lambda x : x)\
.subscribe(lambda val: print(val))
So, how can I solve this problem? I am thinking about grouping each word by it's first character but I dont know how.
[CLOSED]