Python/gloss python for nested

来自菜鸟教程
跳转至:导航、​搜索

<languages />

Python嵌套循环

循环内循环

嵌套循环是循环内部的循环。

“内部循环”将针对“外部循环”的每次迭代执行一次:

为每个水果打印每个形容词:

  adj = ["red", "big", "tasty"]
fruits = ["apple", "banana", "cherry"]


for x in adj:
  for y in fruits:
    print(x, y)