Q:

Overwriting Variable in python issue

I am new to python programming, please assist me.
I don't want to overwrite the Admin but it is forcing me to do that.
def funk(Admin="subhanshu",*users,**additional):
    print("Admin is", Admin)
    print("users are", users)
    print("additional are", additional)

When I run the function, it is throwing an error.
funk(pass,'arun',"abcd",name='prakhar',age=23)
invalid syntex
Please help me how to call a function without over-riding the value of Admin  in the function.

A:

Change the order of parameters in your function signature.
>>> def funk(*users, Admin='subhanshu', **additional):
...     print("Admin is", Admin)
...     print("users are", users)
...     print("additional are", additional)
...
>>> funk('these', 'are', 'all', 'users', this='is', additional=True)
Admin is subhanshu
users are ('these', 'are', 'all', 'users')
additional are {'this': 'is', 'additional': True}

The way that you have defined the function means that the first positional argument passed to the function will always be assigned to the Admin variable. By defining the function so that Admin comes after the positional arguments (*users) with a default value, it becomes an optional keyword argument.

