×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Python
Posted by: Matthew J_
Added: Jun 23, 2022 10:04 AM
Views: 2
Tags: no tags
  1. def make_car(manufacturer, model, **options):
  2.     """Make a dictionary representing a car."""
  3.     car_dict = {
  4.         'manufacturer': manufacturer.title(),
  5.         'model': model.title(),
  6.         }
  7.     for option, value in options.items():
  8.         car_dict[option] = value
  9.  
  10.     return car_dict
  11.  
  12. my_outback = make_car('subaru', 'outback', color='blue', tow_package=True)
  13. print(my_outback)   # {'manufacturer': 'Subaru', 'model': 'Outback', 'color': 'blue', 'tow_package': True}
  14.  
  15. my_accord = make_car('honda', 'accord', year=1991, color='white', headlights='popup')
  16. print(my_accord)