Plan Your Trip! coding clarification [SOLVED]


One question: so I did everything correct however I have issues with indentation on python as I'm learning these lessons.
The same code below would be incorrect if it looked like this:

Why couldn't I indent the "print" rather it has to be in the location same as "def" (way in the front of the editor without any indentation? What is the difference and how does it affect my codes?

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

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


Indentation puts the code inside the function block. It will never be seen by the interpreter, though, since it follows return. Anything after return is unreachable.

No indent puts the code in global scope, the same scope that contains the functions.


Thank you. you're very helpful


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