Pseudocode/Python Project

Pseudocode/Python Project


Hey All.
I am writing a program that uses conditionals as well as a while loop.
I am running into problems with the while loop.
The loop is set to run if the user doesn’t enter ‘yes’ or ‘no’ when asked whether they would like to make a payment. No matter where I try to place the loop it seems to get stuck if I enter anything other than ‘yes’ or ‘no’ then enter either ‘yes’ or ‘no’ after the loop.
It seems that if I try to catch someone not entering either of the two acceptable entries the program gets stuck.

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”)
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))
while (dectopay!=”yes”)or(dectopay!=”no”):
dectopay=input(“We’re sorry. You must answer either ‘yes’ or ‘no’n”)

Credit_card()



Source link
lol

By stp2y

Leave a Reply

Your email address will not be published. Required fields are marked *

No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.