Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Mixing positional and named parameters

We have already seen several built-in functions where we mixed positional arguments with some key-value arguments.

fname = "Foo"
lname = "Bar"
animals = ["snake", "mouse", "cat", "dog"]

print(fname, lname, sep="-", end="\n\n")

by_length = sorted(animals, key=len, reverse=True)
print(by_length)

Output:

Foo-Bar

['snake', 'mouse', 'cat', 'dog']