So I have a code that project the user's bill. I put it on a loop so that it keeps repeating itself until the user don't want to continue.
here is my code:
status = True
def kill() :
confirm = input("Again? (Y/N) : ")
if confirm == "n":
status = False
while(status):
plan_option = input("Which plan are using ? (a/b/c/d/e): ").lower()
if plan_option == "a" :
print("Your current bill is : $90")
kill()
else :
data_amount = float(input("How much data have you used? "))
print("===========================")
def plan_b(x) :
if x < 10 :
print("Your current bill is : $60")
elif x > 10 :
total = 60 + x*10
print("Your current bill is : $", total)
def plan_c(x) :
if x < 5 :
print("Your current bill is : $40")
elif x > 5 :
total = 40 + x*12
print("Your current bill is : $", total)
def plan_d(x) :
if x < 2 :
print("Your current bill is : $30")
elif x > 2 :
total = + x*15
print("Your current bill is : $", total)
def plan_e(x) :
total = x*18
print("Your current bill is : $", total)
if plan_option == "b" :
plan_b(data_amount)
elif plan_option == "c" :
plan_c(data_amount)
elif plan_option == "d" :
plan_d(data_amount)
elif plan_option == "e" :
plan_e(data_amount)
kill()
So my questions are :
- If I enter "n" when the code prompt me, the script won't stop and kept going back to plan_option.
- even though the code stops (eventually), it kept prompting me "Again? (Y/N) : " before it kills itself.
Where did I do wrong? Also, am I over-engineering here?