Where does `create_product` come from?

def create_products(**products_dict):
for name, price in products_dict.items():
create_product(name, price)

Checkpoint 3

Update the call to create_products() to pass in this dictionary as a series of keyword

create_products(
Baseball=‘3’,
Shirt=‘14’,
Guitar=‘70’)
The output says “Baseball created, being sold for $3”
“Shirt created Being sold for $14”
“Guitar created. Being sold for $70”
My question is: is the formatting of the output due to the importing of the create_product? This is somewhat confusing

The create_product function is available in products.py, and looks like this:

def create_product(name, price):
  print("{} created, being sold for ${}".format(name, price))

Certain lessons have more then one files, just look for the folder/directory icon, this will open a file manager allowing you to open the other files of the project/lesson.

14 Likes

Ok, thank you! I didn’t know that

2 Likes

Wow I didn’t know that either, and especially helpful for this lesson. Thanks!

1 Like

Learn Python: Function Arguments

Keyword Argument Unpacking

You can add some code to script.py to sneak a peek into products.py:

with open("products.py") as products:
  products_data = products.read()
  print(products_data)

Which then reveals the create_product() function:

def create_product(name, price):
  print("{} created, being sold for ${}".format(name, price))
2 Likes