关于Python for循环遍历列表的问题

available_toppings={"mushrooms","olives","green peppers",
					"pepperoni","pineapple","extra cheese"}
requested_toppings={"mushrooms","french fries","extra cheese"}

for requested_topping in requested_toppings :
	if requested_topping in available_toppings :
		print("Adding "+requested_topping+".")
	else :
		print("Sorry,we don't have"+requested_topping)

如上,是一个for遍历列表。

三次运行结果如下:

对于同样的内容,怎会出现不同的结果?

猜你喜欢

转载自blog.csdn.net/lumingjia819/article/details/80864858
今日推荐