Oops, try again. It looks like rental_car_cost returns None instead of the correct amount (100) for 3 days.
I'm not sure what to try next. I've modified just about everything I can think of and still no luck, now I've reverted back to my original code which is what I beleive to be correct. It mimics the structure of the example 1:1 so I'm not sure what's wrong.
Let me explain what I think is going on for learning purposes and so I don't just get an answer without knowing why.
- I'm defining a function called rental_car_cost with an argument of (days)
- Within it, I'm creating a new variable called totalCost and setting it equal to 40 times the number of days.
3.If the number of days is greater than or equal to 7, deduct 50 from totalCost. If not, but is greater than or equal to 3 days, deduct only 20 from totalCost.
4.Otherwise, return the totalCost. (Note: I tried adding an else: above return as I felt it could be the problem, but that didn't work.
Also, I've tried adding rental_car_cost(5) above and below return totalCost (even though example doesn't have them) because I don't understand how the code will work without it. This line will set the number of days so without it, how will the rest of the function know how to calculate totalCost? This didn't work when adding, as you probably guessed.
Another side note: The error message seems to be getting 3 total days from somewhere, which is strange as I currently don't have any days set but previously had 5.
def rental_car_cost(days): totalCost = 40 * days if days >= 7: totalCost -= 50 elif days >= 3: totalCost -= 20 return totalCost