Contents tagged with lambda

  • Functions map, zip and lambda in Python

    Hello everybody,

    today I want to describe three elements of Python: map, zip, lambda and *.

    Zip and *

    The first step that I want to describe is zip and * usage. Take a look at the following code:

    a = [5, 6]

    b = [7, 8]

    c = zip(a,b)


    How do you think, what will be output, if I'll tell you that zip function zips arrays? If your guess is (5, 6) (7, 8) then unfortunately you are wrong. Output will be the following:

    (5, 7) (6, 8). I suppose that zip name was chosen because as usually zippers on clothes as usually vertical. Zip functions "zips" elements by columns, like presented on the picture:

    Now one more question, what is purpose of * ? It tells to Python interpreter to … more