因此,Tip_Percentage必须高于15,并且我希望输入循环,如果不满足它的要求,我是如何实现的?
Meal_Cost = int(input("Meal Cost: $"))
Patrons = int(input("Number of Patrons: "))
Tip_Percentage = int(input("Tip %: "))
while Tip_Percentage <= 15:
print("Please give a higher tip than that.")
break
else:
if Tip_Percentage >= 15:
print('\n')
Price_of_Meal = Meal_Cost / Patrons
print("Price of Meal: $", Price_of_Meal,)
Tip_Amount = (Tip_Percentage / 100 * Meal_Cost)
print("Tip: $", Tip_Amount)
答案 0 :(得分:1)
再次询问Tip_Percentage输入:
Tip_Percentage = int(input("Tip %: "))
while Tip_Percentage <= 15:
print("Please give a higher tip than that.")
Tip_Percentage = int(input("Tip %: "))
答案 1 :(得分:0)
你必须要求提示,直到它大于或等于15。
Meal_Cost = int(input("Meal Cost: $"))
Patrons = int(input("Number of Patrons: "))
Tip_Percentage = int(input("Tip %: "))
while Tip_Percentage <= 15:
Tip_Percentage = int(input("Please give a higher tip than that : "))
Price_of_Meal = Meal_Cost / Patrons
print("Price of Meal: $", Price_of_Meal,)
Tip_Amount = (Tip_Percentage / 100 * Meal_Cost)
print("Tip: $", Tip_Amount)