Created
August 9, 2023 10:58
-
-
Save bbelderbos/2e6e42cf7d34d718e353442836399b7d 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
# ok | |
def create_person(*args): | |
first_name, last_name, age = args | |
return { | |
'First Name': first_name, | |
'Last Name': last_name, | |
'Age': age | |
} | |
# Caller assumes the order: first name, last name, age. | |
person = create_person('John', 'Doe', 30) | |
print(person) # Outputs: {'First Name': 'John', 'Last Name': 'Doe', 'Age': 30} | |
# not ok | |
def create_person(*args): | |
# The order has changed to: age, first name, last name. | |
age, first_name, last_name = args | |
return { | |
'First Name': first_name, | |
'Last Name': last_name, | |
'Age': age | |
} | |
# Caller still assumes the old order: first name, last name, age. | |
person = create_person('John', 'Doe', 30) | |
print(person) # Outputs: {'First Name': 'Doe', 'Last Name': 30, 'Age': 'John'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment