Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def build_person(first_name, last_name, middle_name='', age=None):
- if middle_name and age:
- person = {'first' : first_name, 'middle' : middle_name, 'last' : last_name, 'age': age}
- elif middle_name:
- person = {'first' : first_name, 'middle' : middle_name, 'last' : last_name}
- elif age:
- person = {'first' : first_name, 'last' : last_name, 'age': age}
- else:
- person = {'first' : first_name, 'last' : last_name}
- return person
- musician = build_person('John', 'Hooker') #musician -> dict
- print(musician)
- musician = build_person('John', 'Hooker', 'Lee')
- print(musician)
- musician = build_person(first_name='John', last_name='Hooker', age=40)
- print(musician)
- musician = build_person('John', 'Hooker', 'Lee', 40)
- print(musician)
Advertisement
Add Comment
Please, Sign In to add comment