Python 嵌套循环
循环嵌套
嵌套循环是指循环里面嵌套循环。
"内层循环" 每次 "外层循环" 迭代都会执行一次。
例子
为每种水果打印每个形容词
adj = ["red", "big", "tasty"]
fruits = ["apple", "banana", "cherry"]
for x in adj
for y in fruits
print(x, y)
自己尝试 »
嵌套循环是指循环里面嵌套循环。
"内层循环" 每次 "外层循环" 迭代都会执行一次。
为每种水果打印每个形容词
adj = ["red", "big", "tasty"]
fruits = ["apple", "banana", "cherry"]
for x in adj
for y in fruits
print(x, y)
自己尝试 »
If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]
If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]