What's wrong with my code?


#1

I have a problem with an exercice :

https://www.codecademy.com/fr/courses/python-beginner-fr-FR-gi6pz/1/5?curriculum_id=5370f030fed2a866a2000001

It says me that : Be sure that voyage_cout take exactly three settings : ville, jours, and depense_argent (in this order).

def hotel_cout(ville):
    return 140*nuits
    
def avion_billet_cout(ville):
    if ville == "Charlotte":
        return 183
    elif ville == "Tampa":
        return 220
    elif ville == "Pittsburgh":
        return 222
    elif ville == "Los Angeles":
        return 475
    
def location_voiture_cout(jours):
    
    if jours >=7:
        return (40*jours)-50
    elif jours >=3:
        return (40*jours)-20
    else:
        return 40*jours
        
def voyage_cout(ville, jours, depense_argent):
    return ville + jours + depense_argent

I search but I can't find my error :confused:

And sorry if my english isn't correct !


#2

The error message does not reflect what's wrong with your code. You're actually getting a TypeError when voyage_cout is called, because you're appending numbers (jours and depense_argent) to a string ville. You first have to convert both the numbers to strings (using the str function).


#3

Oh okaay, tanks for your fast answer :smiley: