def kitchen():
    kitchen_items = [
    "Rice", "Chickpeas", "Pulses", "bread", "meat",
    "Milk", "Bacon", "Eggs", "Rice Cooker", "Sauce",
    "Chicken Pie", "Apple Pie", "Pudding"
    ]

我尝试阅读PEP8,但是我从那里得到的唯一一件事是-



我真的不明白那是什么意思。很抱歉,我没有正确阅读它。

最佳答案

您需要像这样缩进列表内容

kitchen_items = [
    "Rice", "Chickpeas", "Pulses", "bread", "meat",
    "Milk", "Bacon", "Eggs", "Rice Cooker", "Sauce",
    "Chicken Pie", "Apple Pie", "Pudding"
]

或者
kitchen_items = [
    "Rice", "Chickpeas", "Pulses", "bread", "meat",
    "Milk", "Bacon", "Eggs", "Rice Cooker", "Sauce",
    "Chicken Pie", "Apple Pie", "Pudding"
    ]

关于python - 这是用Python编写长列表的最干净的方法吗?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22978997/

10-11 01:40