There’s nothing wrong with having a while
loop inside a for
loop.
To demonstrate:
i = 0
kebab = ["chicken","garlic","cheese","tomato","lettuce","chilli"]
print "Kebabs are so good, this is what mine has:"
excitement_over_kebab = 1
for ingredients in kebab:
while excitement_over_kebab == 1:
print kebab[i]
i+=1
if i == 6:
print "Enough talk, my lunch break is over."
excitement_over_kebab = 0
Output:
Kebabs are so good, this is what mine has:
chicken
garlic
cheese
tomato
lettuce
chilli
Enough talk, my lunch break is over.
1
solved While loop inside of for loop [closed]