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 matt…


This content originally appeared on DEV Community and was authored by TheFoxlion

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()


This content originally appeared on DEV Community and was authored by TheFoxlion


Print Share Comment Cite Upload Translate Updates
APA

TheFoxlion | Sciencx (2024-06-22T01:02:58+00:00) Pseudocode/Python Project. Retrieved from https://www.scien.cx/2024/06/22/pseudocode-python-project/

MLA
" » Pseudocode/Python Project." TheFoxlion | Sciencx - Saturday June 22, 2024, https://www.scien.cx/2024/06/22/pseudocode-python-project/
HARVARD
TheFoxlion | Sciencx Saturday June 22, 2024 » Pseudocode/Python Project., viewed ,<https://www.scien.cx/2024/06/22/pseudocode-python-project/>
VANCOUVER
TheFoxlion | Sciencx - » Pseudocode/Python Project. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/06/22/pseudocode-python-project/
CHICAGO
" » Pseudocode/Python Project." TheFoxlion | Sciencx - Accessed . https://www.scien.cx/2024/06/22/pseudocode-python-project/
IEEE
" » Pseudocode/Python Project." TheFoxlion | Sciencx [Online]. Available: https://www.scien.cx/2024/06/22/pseudocode-python-project/. [Accessed: ]
rf:citation
» Pseudocode/Python Project | TheFoxlion | Sciencx | https://www.scien.cx/2024/06/22/pseudocode-python-project/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.