-1

Practicing some logic and wondering why none of my conditions are not being met even after entering valid input. I enter 0, 6 or 12 and the result remains the same where it says it does not recognize any choice I selected. This is the code:

import os

remain_bal = 0
user_name = str(input("Please enter your name"))
while user_name != "END":
    final_price = float(input("enter the final cost of the device you purchased"))
    code_plan = str(input("Please enter the code"))
    payment_plan = str(input("Which payment plan are you on? Enter 6 for six months plan or 12 for twelve months plan or 0 for full"))
    num_payments = int(input("How many payments have you made? (Enter integer values)"))

    if payment_plan == 0:
        remain_bal = (final_price - final_price)

    elif payment_plan == 6:
        remain_bal = final_price - (final_price / 6) * num_payments

    elif payment_plan == 12:
        remain_bal = final_price - (final_price / 12) * num_payments

    else:
        print("The plan you selected is not on the list select 0, 6 or 12")

    print("Your balance remaining is", remain_bal)
    user_name = str(input("Please enter your name"))

This is the output:

code output

What logic am I overlooking?

AJ26
  • 501
  • 4
  • 15

1 Answers1

1

You have the variable payment_plan as a string, but are comparing it to integer 6, and objects of different classes are not equivalent. Either change the variable to an int like your other input variables, or change the test to "6".

goalie1998
  • 1,427
  • 1
  • 9
  • 16