0
c=map(lambda *x:x, range(3))
print(list(c))

c=map(lambda x:x, range(3))
print(list(c))

Can someone tell me how is the output different if we use variable positional args

[(0,), (1,), (2,)] #1st output

[0, 1, 2] #2nd output
dfundako
  • 8,022
  • 3
  • 18
  • 34
Randy
  • 79
  • 6
  • 1
    This has nothing to do with `map` or `lambda` per se, you are really just asking how variable positional arguments work. When you use `def func(*args):` then `args` will be a *tuple* of the objects passed by the caller of `func`, so `func(1,2,'foo')` will give you `args == (1, 2, 'foo')`, if you only pass a single argument, then you will have a singleton tuple: `func(1)` will give you `args == (1,)` – juanpa.arrivillaga Aug 30 '19 at 18:28
  • much appreciated..ty – Randy Aug 30 '19 at 18:47

0 Answers0