I am writing a program that guides users through making a payment on their credit card but, I am running into problems when the user enters anything other than ‘yes’ or ‘no’ when asked if they would like to make a payment.
I tried
def Credit_card():
ccb=float(input("What is your credit card balance?n"))
pur=float(input("How much have you spent in purchases?n"))
minpymt=pur*.12
print("Your minimum payment is ${0}".format(minpymt))
dectopay=input("Would you like to make a payment?n Please type 'yes' or 'no'n")
while (dectopay!='yes'or'no'):
input("We're sorry. You must answer either 'yes' or 'no'.n Would you like to make a payment?n")
if(dectopay=="yes"):
pymt=float(input("Wonderful! How much would you like to pay?n"))
while(pymt<minpymt):
pymt=float(input("We're sorry, but your payment must be greater than or equal to your minimum payment of ${0}nHow much would you like to pay?n").format(minpymt))
print("Thank you for your payment!n")
print("Your new credit card balance is ${0}n".format((ccb+pur)-pymt))
elif(dectopay=="no"):
print("Your credit card balance is ${0}. Thank you for visiting Credit Central. n Have a wonderful day!".format(ccb+pur))
Credit_card()
Which, after I enter ‘yes’ or ‘no’ I was hoping the loop would cancel. The condition for the loop is that:
(dectopay!='yes'or'no')
which should end if they do equal either yes or no right?
Let me know. I am gonna skip this sidequest and continue with some html/css/java stuff because getting stuck on such a mundane task seems like a waste of time. I still want the program to do what I want though.
Thanks for any help.
Matthew William Barnes is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.