Home > AI > Language > Python >

*args, **kwargs

Example 1: check kwargs key


def test(*args, **kwargs):
    if "outer" in kwargs:
        print("Outer, {}".format(kwargs["outer"]))
    elif "inner" in kwargs:
        print("Inner, {}".format(kwargs["inner"]))
    else:
        print("Good")
        
        
test(outer="a")
test(inner="b")
test()

Leave a Reply