8/11


#1



https://www.codecademy.com/fr/courses/python-intermediate-fr-FR-ejrp4/1/2?curriculum_id=5370f030fed2a866a2000001


Don't know what is wrong.


class Voiture(object):
    condition = "nouveau"
    def __init__(self, modele, couleur, mpg):
        self.modele = modele
        self.couleur = couleur
        self.mpg   = mpg
        
    def afficher_voiture(self):
        return "ceci est" + self.modele + ""  + self.couleur +  "avec"  + str(self.mpg) + "MPG."
        
    def conduire_voiture():
    self.condition = "usé"

ma_voiture = Voiture("DeLorean", "argent", 88)
print ma_voiture.condition
ma_voiture.conduire_voiture()
print ma_voiture.condition

Traceback (most recent call last):
  File "python/cli_runner.py", line 152, in <module>


#2

@snakefinger33gmail.c,
Try it with

class Voiture(object):
    condition = "nouveau"
    def __init__(self, modele, couleur, mpg):
        self.modele = modele
        self.couleur = couleur
        self.mpg   = mpg
        
    def afficher_voiture(self):
        return "ceci est" + self.modele + ""  + self.couleur +  "avec"  + str(self.mpg) + "MPG."
        
    def conduire_voiture(self):
        self.condition = "usé"

changes made to conduire_voiture()

  • -1 added self-keyword as parameter
    conduire_voiture(self)
  • -2 changed the indentation

8/11
#3

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