Home > OS >  getting name error? total_charge is undefind
getting name error? total_charge is undefind

Time:09-17

if code == "B":
  based_charge: int(40 * days)
  mileage_charge = driven * .25
  total_charge = mileage_charge   based_charge

CodePudding user response:

Have you defined what "days" and "driven" is?

Your code should look either like this:

if code == "B":
  days = 4 #Example, define some number of days
  driven = 10 #Example, define how much you've driven already
  based_charge = int(40 * days)
  mileage_charge = driven * .25
  total_charge = mileage_charge   based_charge

or like this (if you've predefined "days" and "driven":

days = 4 #Example, define some number of days
driven = 10 #Example, define how much you've driven already
if code == "B":  
  based_charge = int(40 * days)
  mileage_charge = driven * .25
  total_charge = mileage_charge   based_charge

Hope I helped and happy coding!

  • Related