I'm an amateur programmer, and I have come across an issue with a for statement. So my code works, it prints out what it needs to print. However, the issue lies in the fact that the loop will iterate over the entire list until it finds the correct element. The output looks like this if its the fifth element:
Wrong Answer, Wrong Answer, Wrong Answer, Wrong Answer, Correct Answer
All, I want if for the correct answer to be displayed. Would a flag variable enable this? or do I create a temporary variable to store the correct info in and print that. The help would be awesome, also an explanation of how it works too would be nice as well.
for i in range(len(addIns)):
addIns[i] == addInPrices[i]
if addIns[i] == addIn:
print(addIn, "Price is", addInPrices[i] + orderTotal)
break
else:
print("Sorry, we do not carry that")