7. Plan your trip


#1

Hi Guys, please help!
I don't know what I've done wrong :frowning:

Its saying "nothing is printing to console"

def hotel_cost(nights):
    return 140 * nights
    
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):
    cost = 40*days
    if days >= 7:
        cost -= int(50)
    elif days >= 3 and days <= 7:
        cost -= int(20)
    return cost
    
def trip_cost(city, days, spending_money):
    return plane_ride_cost(city) + rental_car_cost(days) + hotel_cost(days) + spending_money
    print trip_cost("Los Angeles", '5', '600')

#2

i just got finish with this, so i'd like to help others now as i ask for help to others also..

your code in print was a bit off because you make '5' and '600' a string... that should be left int.
print trip_cost("Los Angeles", '5', '600')

("Los Angeles", 5, 600)


#3

Hi there,

I just tried these changes but still getting "nothing was printed to console" :frowning:


#4

are you calling do it like this?

print ("Los Angeles", 5, 600)

or were you just typing
("Los Angeles", 5, 600) ?

You need to use the first example with print before it.


#6

Can anyone point out my errors here?


#7

I was stuck on this problem for an hour. Just figured it out print must be aligned to the left not indented.


#8

Thank you very much.


#10

Hi @nrgwood,

Hint: Your print statement should be outside the trip_cost function.


#11

2 posts were split to a new topic: Unsupported operand type(s) for +: 'NoneType' and 'int' Exercise 7


#12

I don't understand. What do you mean aligned to the left?


#13

Can you post an image of your code please?


#14

Thank you very much. Took me over 2 hours and only when I saw your comment I realized what I was doing wrong. The solution was so simple the print command is a new command and not pat of the trip_cost function.
Noticed that problems often occur due to wrong indentation.


#15

@labibsharrar @thorshammer76 means that the print statement should be outside the trip_cost function. By indenting it to the right, you move it inside the trip_cost function. By indenting it to the left, you move it outside the trip_cost function.


#16

Thank you for posting this. I had the same problem and thankfully found your explanation within minutes of making the mistake.


#17

3 posts were split to a new topic: Plan your trip