我一直在使用这个 python 代码时遇到问题。我刚开始编码,我不知道为什么它不起作用。我无法让循环停止重复。无论我输入什么,它都会启动 add_item 函数。有小费吗?
supply = { #Creates blank dictionary
}
print "Would you like to add anything to the list?"
def add_item(*args): #Adds a item to the supply dictionary
print "What would you like to add?"
first_item = raw_input()
print "How much does it cost?"
first_price = raw_input()
supply[first_item] = float(first_price)
response = raw_input()
while response == "yes" or "Yes" or "YES":
if response == "yes" or "Yes" or "YES": #Added this because it wasn't working, didn't help
add_item()
print "Alright, your stock now reads:", supply
print "Would you like to add anything else?"
response = raw_input()
elif response == "no" or "No" or "NO":
print "Alright. Your stock includes:"
print supply
break
else:
print "Sorry I didn't understand that. Your stock includes:"
print supply
break
print "Press Enter to close"
end_program = raw_input()