How to print a list of items in Python?
To print a list of products, you can use the following code example:
# 定义商品列表
products = ["苹果", "香蕉", "橙子", "西瓜", "葡萄"]
# 打印商品列表
for product in products:
print(product)
This code segment starts by defining a list of products called “products” that includes various types of fruits. Next, it uses a for loop to iterate through each product in the list and prints it using the print() function. Each product is printed on a separate line.