Q:

Using lambda function in python

I just came across lambda function in python, so just tried to play with it.
Here I tried
a="ABCD"
b=map(lambda x:a[int(x)],a)
print(list(b))

And this gives error
ValueError: invalid literal for int() with base 10: 'A'
but was expecting O/P like this 
[A,B,C,D]
Any explanation on this .
Thanks

A:

int(x) yields your error, since you can not convert "A" into an integer
Correct would be:
a="ABCD"
b=map(lambda x:x,a)
print(list(b))

As mentioned in the comments, the following gives the same result:
print(list(a))

You should probably check out some more lambda tutorials first: http://www.secnetix.de/olli/Python/lambda_functions.hawk

