I am trying to learn the functional programming way of doing things in python. I am trying to serialize a list of strings in python using the following code
S = ["geeks", "are", "awesome"]
reduce(lambda x, y: (str(len(x)) + '~' + x) + (str(len(y)) + '~' + y), S)
I am expecting:
5~geeks3~are7~awesome
But I am seeing:
12~5~geeks3~are7~awesome
Can someone point out why? Thanks in advance!