【发布时间】:2021-08-14 02:11:38
【问题描述】:
colours = ["red", "green", "blue"]
clothes = ["shirt", "dress", "pants", "jacket", "hat"]
for colour_item in colours:
for clothes_item in clothes:
print("I am wearing a ",colour_item," ",clothes_item)
这是我试图更改为 while 循环以产生所有结果的代码,即 15 个结果,我可以使用 while 循环获得的最佳结果是 3。
【问题讨论】:
-
为什么要为此使用 while 循环?
-
包括你的while循环代码。
标签: python for-loop while-loop