IDLE Python 3.6


#1



https://www.codecademy.com/courses/python-beginner-P5YtY/1/6?curriculum_id=4f89dab3d788890003000096


My codes on codecademy doesn't work on the program I downloaded (called IDLE Python 3.6 64-bit).


To run the exact same code.


def hotel_cost(nights): #hotel costs 140$/night
    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):
    cost = days * 40
    if days >= 7:
        cost = cost - 50
        return cost
    elif days >= 3:
        cost = cost - 20
        return cost
    else:
        return cost
def trip_cost(city, days, spending_money):
    return (hotel_cost(days) + rental_car_cost(days) + plane_ride_cost(city) + spending_money)

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


#2

python3 is not backward compatible with python2, which codecademy uses.

the only problem i see in your code, is that print requires parentheses because its a function call in python3:

# python3
print("hello world")
# python2
print "hello world"

#3

Still have a problem, check this out.


#4

You didn't update print from a statement to a function call? You need to add the parentheses to make print a function call:

you didn't. Is there something unclear about it? In my example i used a simple string, this is not the case with your code, but the difference is still clear, right?


#5

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