Taking a Vacation : Transportation


#1



Hi, can someone try to helping with this code? If the syntax is wrong or anything else? right now I have problems with Indentation. Please can you post me an answer with the tool "preformatted text"? It's very important. Thanks

error message:
File "python", line 25
    print total
   ^
IndentationError: unexpected indent

but I don't know if there are others.


def rental_car_cost(days):
    total = 40*days
    if days>=7 :
       total= total - 50
       print total
       return total
      
    elif days>=3 :
        total = total -20
          print total
          return total

I have tried also this:

def rentalCarCost(days):
    rentalCost = days * 40
    if days >= 3 and days < 7:
        return rentalCost - 20
    elif days >= 7:
        return rentalCost - 50
    else:
        return rentalCost
print rentalCarCost(10)

with this error:
Oops, try again. It looks like rental_car_cost returns None instead of the correct amount (40) for 1 days.
can someone help me?


#2

For your first code, just line up your print total and return total with total = total - 20.

For the second one, your function name should be rental_car_cost instead of rentalCarCost.

You were very close for both codes you posted.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.