xxxxxxxxxx
#Forced keyword parameter
def foo(a, b, *, c, d): # all parameters after * must be keyword arguments
print(a, b, c, d)
foo(1, 2, c=3, d=4) #1 2 3 4
# foo(1, 2, 3, 4) #TypeError: foo() takes 2 positional arguments but 4 were given
def foo(*args, last):
for arg in args:
print(arg, end = ' ')
print(last)
foo(1, 2, 3) #TypeError: foo() missing 1 required keyword-only argument: 'last'
foo(1, 2, 3, last=100) #1 2 3 100