Fulltimehustle
Fulltimehustle

Reputation: 29

What is wrong with this program in order to update the value of cost with multiple variables?

I am not sure what to do in order to update the assigned variable cost in reference to the if statements

Ive tried multiple things such as indentation, elif statements, adding additional BASE_RATE + BASE_RATE variables

BASE_RATE = 75

cost = BASE_RATE

if sex == 'M':  # add another equal sign

    cost = BASE_RATE + (BASE_RATE * .25)

if state == 'OH' or state == 'MO':

    cost = BASE_RATE + (BASE_RATE * .10)  

if age < 21 or age > 70:

    cost = BASE_RATE + (BASE_RATE * .05)  

No error messages, need to carry over the new assigned values to cost if sex == M is true and state == OH is true but age is between 21 and 69

Upvotes: 0

Views: 54

Answers (1)

tituszban
tituszban

Reputation: 5152

you must be new to Python. You can update the value and increment it with the base rate:

BASE_RATE = 75

cost = BASE_RATE

if sex == 'M':  # add another equal sign
    cost += (BASE_RATE * .25)

if state == 'OH' or state == 'MO':
    cost += (BASE_RATE * .10)  

if 21 < age < 70:
    cost += (BASE_RATE * .05)  

Upvotes: 1

Related Questions