Reputation: 53
In the last line of the code below, I want to go back to the top of the for loop, but still have code below in case the answer isn't 'no'.
for i in range(13):
choice = input('Would you like a '+comp_choice[i]+'? Yes or no: ')
if choice == 'yes':
items+=comp_choice[i]
stock[i]-=1
elif choice == 'no':
Upvotes: 1
Views: 68
Reputation: 1568
What you are looking for is continue
.
It exists is procedural languages.
The continue
keyword is used to stop the current iteration of a loop, no code will be executed if you call it.
Unlike the break
keyword, which will interrupt the loop, continue
will proceed with the next iteration.
If I understood you question right, this is exactly what you need.
Upvotes: 1