Created
March 21, 2017 00:12
-
-
Save mingrammer/94075ef4dbabc49f1533b41c866487f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A function that shows the results of running competitions consisting of 2 to 4 runners. | |
def save_ranking(first, second, third=None, fourth=None): | |
rank = {} | |
rank[1], rank[2] = first, second | |
rank[3] = third if third is not None else 'Nobody' | |
rank[4] = fourth if fourth is not None else 'Nobody' | |
print(rank) | |
# Pass the 2 positional arguments | |
save_ranking('ming', 'alice') | |
# Pass the 2 positional arguments and 1 keyword argument | |
save_ranking('alice', 'ming', third='mike') | |
# Pass the 2 positional arguments and 2 keyword arguments (But, one of them was passed as like positional argument) | |
save_ranking('alice', 'ming', 'mike', fourth='jim') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment