0

So, the Tip_Percentage must be higher than 15, and I want the input to loop if the requirement for it to be over 15 isn't met, how I make that happen?

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)

2 Answers2

1

Ask for the Tip_Percentage input again:

Tip_Percentage = int(input("Tip %: "))

while Tip_Percentage <= 15:
    print("Please give a higher tip than that.")
    Tip_Percentage = int(input("Tip %: "))
TerryA
  • 58,805
  • 11
  • 114
  • 143
0

You need to ask for the tip until it has been greater than or equal to 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)
yash
  • 1,357
  • 2
  • 23
  • 34