Entire lesson worked just fine until the last 2 steps

I have the same issue. The entire lesson worked just fine until the last 2 steps. The second to last one I kept getting errors with until I finally gave in and hit the get code button. But that just reset my workspace but still allowed me to move on. Now when I click run, it just spins.
My code looks like this:

def hotel_cost(nights):
return 140 * nights

def plane_ride_cost(city):
if city == ()“Charlotte”):
return 183
elif city == ()“Tampa”):
return 220
elif city == ()“Pittsburgh”):
return 222
elif city == ()“Los Angeles”):
return 475

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

def spending_money(money):
return money

def trip_cost(city, days, spending_money):
return hotel_cost(nights) + plane_ride_cost(city) + rental_car_cost(days) + spending_money(money)

print trip_cost(“Los Angeles”, 5, 600)

That is not asked for, nor expected.

1 Like

Deleting that still didn’t fix the issue. Still just spins when I hit run

Did you fix that, too?

1 Like

Still just spins
This is the current code:

def hotel_cost(nights):
return 140 * nights

def plane_ride_cost(city):
if city == (“Charlotte”):
return 183
elif city == (“Tampa”):
return 220
elif city == (“Pittsburgh”):
return 222
elif city == (“Los Angeles”):
return 475

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

def trip_cost(city, days, spending_money):
return hotel_cost(nights) + plane_ride_cost(city) + rental_car_cost(days) + spending_money

print trip_cost(“Los Angeles”, 5, 600)

nights is defined in the hotel_cost function and is local, only. Use days in the caller argument since that variable is defined in your trip_cost parameters.

Also, don’t parenthicize the expression in your conditionals.

if city == "Los Angeles"
1 Like

So it should look like this?

def hotel_cost(nights):
return 140 * nights

def plane_ride_cost(city):
if city == “Charlotte”:
return 183
elif city == “Tampa”:
return 220
elif city == “Pittsburgh”:
return 222
elif city == “Los Angeles”:
return 475

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

def trip_cost(city, days, spending_money):
return city + days + spending_money

print trip_cost(“Los Angeles”, 5, 600)

Because that still doesn’t work. Idk what is causing it to just spin forever.

I’ve now tried 2 different browsers and I still get the hang up when I hit run. Is there something wrong with my code or is it something wrong with the platform? I’m getting quite frustrated

return plane_ride_cost(city) + hotel_cost(days) + rental_car_cost(days) + spending_money
1 Like

Do you have any other help? I changed it so it looks like this:

def hotel_cost(nights):
  return 140 * nights

def plane_ride_cost(city):
  if city == "Charlotte":
    return 183
  elif city == "Tampa":
    return 220
  elif city == "Pittsburgh":
    return 222
  elif city == "Los Angeles":
    return 475
  
def rental_car_cost(days):
    total = days * 40
    if days >= 7:
      return total - 50
    elif days >=3:
      return total -20
    else:
      return total
    
def trip_cost(city, days, spending_money):
  return plane_ride_cost(city) + hotel_cost(days) + rental_car_cost(days) + spending_money

print trip_cost("Los Angeles", 5, 600)

and it still spins. I have to refresh the entire page to try running the code again and it gives me an error saying that my code has moved and to either replace it or reset my workspace, but it deletes everything anyway.

On the off chance that the SCT is only expecting four space indents, adjust your code to that spec.

I tried that. Went back and re aligned them and then added spaces instead of tab and it still hangs. I’ve copy pasted my code. I’ve re-typed my code. Every time I have to refresh the page, I get the error, “1/script.py has been moved. This will cause problems with this exercise, please move 1/script.py back to its original location, or reset your files”

1 Like

A post was split to a new topic: Please tell me what I did wrong

exactly the same problem with me , if could solve this I would be glad if you share this with me

So long as we are sure your code is 100% correct, there’s nothing more I can suggest. Moving this topic into Platform Problems.

Please submit a bug report that gives a link to the exercise, your OS and browsers you have tried.

1 Like

I found the solution here:
https://discuss.codecademy.com/t/script-py-has-been-moved-error-message/200027/24

So to fix the issue, go back, then reset the workspace, then go forward, and then run the code, either via copy-paste or re-typing

2 Likes

That thought crossed my mind… Don’t know why I didn’t post it. I have before.

One carry away is the indentaion suggestion. Always use four space indent for each level to be on the safe side of the SCT.

When you said 4 space, that means that any indentation is 4 spaces? So that means that a second indent would be 8 spaces?

Correct. Four spaces per block level. The more consistent we keep our source code, the better chance of it not being an issue for the SCT. Besides, we develop a good working habit that follows the practice of the best in the business (as in, making the most money).

1 Like

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