Python Forum
Trying to get an if..elif..else statement to run.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trying to get an if..elif..else statement to run.
#4
I have changed the relevant code to be as such after debugging it:

whatIsOwedBack = anythingLeft * -1
    listOfWhatIsOwedBack = [i for i in str(whatIsOwedBack)]
    if (listOfWhatIsOwedBack[-1] == "1" or listOfWhatIsOwedBack[-1] == "2"):
        listOfWhatIsOwedBack[-1] = "0"
    elif (listOfWhatIsOwedBack[-1] == "3" or listOfWhatIsOwedBack[-1] == "4" or listOfWhatIsOwedBack[-1] == "6" or listOfWhatIsOwedBack[-1] == "7"):
        listOfWhatIsOwedBack[-1] = "5"
    else:
        listOfWhatIsOwedBack[-1] == "8" or listOfWhatIsOwedBack[-1] == "9"
        listOfWhatIsOwedBack[-1] = "0"
        print(listOfWhatIsOwedBack)
After following the link and taking the suggestions into account, it appears that nothing has changed, except that it seems to have stopped reading the code after either print statement, not even reading the variable listOfWhatIsOwedBack.

afterPennyAbolishCoinsLeftAfterCheck()
Enter the floating point numbers representing the item cost and the amount paid respectively
302.57
3.03
Here's your change: 0.0 100$ Bill(s), 0.0 50$ Bill(s), 0.0 20$ Bill(s), 1.0 Toonie(s), 0.0 Loonies, 3.0 Quarter(s), 2.0 Dime(s) and 0.0 Nickel(s)
Reply


Messages In This Thread
RE: Trying to get an if..elif..else statement to run. - by Azurato - Jul-29-2019, 10:57 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020