while True:
user_wants = raw_input("What price should be added to meal? (tax, tip, both) ")
if user_wants == 'tax':
cost_tax = input("What is the meal's cost? ")
tax_cost = 1.08 * cost_tax
tax = tax_cost - cost_tax
print "The price with tax is %s, tax is %s" % (tax_cost, tax)
continue_tax = raw_input("Do you want to continue? (y/n) ")
if continue_tax == 'y':
continue
elif continue_tax == 'n':
break
else:
#What to put here?
elif user_wants == 'tip':
cost_tip = input("What is the meal's cost? ")
tip_cost = 1.10 * cost_tip
tip = tip_cost - cost_tip
print "The price with tip is %s, tip is %s" % (tip_cost, tip)
break
elif user_wants == 'both':
cost_both = input("What is the meal's cost? ")
both_cost = (1.08 * cost_both - cost_both) + (1.10 * cost_both - cost_both) + cost_both
both = both_cost - cost_both
print ("The price with both tip and tax is %s, tax + tip is %s" % (both_cost, both))
break
else:
print ("I didn't catched that please enter again ")
私はオンラインで検索しましたが、役立つものが見つかりませんでした。Pythonで入力を再利用するには?
を試してみてください。あなたの最終的な 'print'はインデントされるべきです。私はちょうど内側の 'if'を見つけましたが、あなたの圧痕はどこにでもあります。あなたはPythonで一貫した字下げを使用する必要があります - これはオプションではありません。 – cdarke