1. 使用列表存储商品名称和价格:
product_list = [('iPhone', 7800),('Mac Pro', 12000),('Watch', 3000),('Shoes', 900),('Coffee', 50)]
2. 使用列表存储商品名称:
product_list = ['iPhone','Mac Pro','Watch','Shoes','Coffee']
3. 使用列表存储商品名称和价格,每个商品作为一个元组:
product_list = [('iPhone', 7800),('Mac Pro', 12000),('Watch', 3000),('Shoes', 900),('Coffee', 50)]
4. 使用列表推导式创建商品列表:

product_list = [f'{name} - ${price}' for name, price in [('iPhone', 7800), ('Mac Pro', 12000), ('Watch', 3000), ('Shoes', 900), ('Coffee', 50)]]
5. 使用字典存储商品名称和价格:
product_list = {'iPhone': 7800,'Mac Pro': 12000,'Watch': 3000,'Shoes': 900,'Coffee': 50}
6. 使用字典存储商品名称和价格,每个商品作为一个键值对:
product_list = {'iPhone': 7800,'Mac Pro': 12000,'Watch': 3000,'Shoes': 900,'Coffee': 50}
打印商品列表可以使用`for`循环遍历列表并打印每个商品:
for product in product_list:print(product)
以上是创建和打印商品列表的基本方法。您可以根据实际需求选择合适的数据结构来存储商品信息。
