Unpacking

We can unpack using * symbol. This will unpack List, String, etc. For example:

a, b, *_ = [1,2,3,4,5,6]
print(_)
[3,4,5,6]

Similarly, when using with arguments:

def func1(*args):
    return [*args]

if __name__ == "__main__":
    print(func1(1,2,3,4))
[1,2,3,4]

For dictionary, we can use ** to unpack, for example:

if __name__ == "__main__":
    dict1 = {"one": 1, "two": 2}
    dict2 = {"three": 3, "four": 4}
    merged_dict = {**dict1, **dict2}
    
    print(merged_dict)
{'one': 1, 'two': 2, 'three': 3, 'four': 4}