0

I have a code snippet which is as follows:

def myfunc(**kwargs):
    print("I work with the follwoing people: ")
    for people in kwargs:
        print (kwargs[people])


mydict = {'person1': "Faraz", 'person2': "Rukhshan", 'person3': "Muzammil"}

myfunc(**mydict)

I dont see any use of unpacking because we can do the same things in the following way:

def myfunc(kwargs):
        print("I work with the follwoing people: ")
        for people in kwargs:
            print (kwargs[people])
    
    
mydict = {'person1': "Faraz", 'person2': "Rukhshan", 'person3': "Muzammil"}
    
myfunc(mydict)

It yeilds the same result.

Reactoo
  • 916
  • 2
  • 12
  • 40
  • The point of having `def myfunc(**kwargs)` is exactly that you *don't* have to do `myfunc(**mydict)` when calling the function – DeepSpace Nov 24 '22 at 17:57

0 Answers0