Referring to member variables - double standards on codecademy


#1



Link -->> https://www.codecademy.com/courses/python-intermediate-en-egNXj/0/6?curriculum_id=4f89dab3d788890003000096#

The error for the first line: Oops, try again. The color of my_car should be "silver". Name "my" is not defined. ????? I did not try to define my I defined my_car and nowhere does it say the car needs to be silver. This is not the first time I have had these problems with codecademy and in past exercises I have let it go but this time I cannot move forward without questioning something like this. Programming is tough so I don't want to leave any small matter misunderstood so apologies if this is too long and you didn't read.


First I will show my wrong code that shows up an error and the 2nd line of code passes perfectly.


class Car(object):
    condition = "new"
    def __init__(self, model, color, mpg):
        self.model = model 
        self.color = color 
        self.mpg = mpg 
 
my_car = Car("Ferrari", "Red", 21)
print my.car.condition
print my_car.model
print my_car.color
print my_car.mpg

#The error for the above is: Oops, try again. The color of my_car should be "silver". Name "my" is not defined. ????? I did not try to define my I defined my_car and nowhere does it say the car needs to be silver. This is not the first time I have had these problems with codecademy and in past exercises I have let it go but this time I cannot move forward without questioning something like this. Programming is tough so I don't want to leave any small matter misunderstood so apologies if this is too long and you didn't read. 

class Car(object):
    condition = "new"
    def __init__(self, model, color, mpg):
        self.model = model
        self.color = color
        self.mpg = mpg
    
my_car = Car("DeLorean", "silver", 88) 

print my_car.condition
print my_car.model 
print my_car.color
print my_car.mpg


#2

this line:

print my.car.condition

the instance is my_car, seems you made a small typo

as for the color, sometimes you get away with it in the exercises, sometimes you don't.


#3

Problem1.
print my.car.condition

my_car or my.car?

Problem2.
They have mentioned to pass these parameters
"DeLorean","silver", 88 (back to previous exercise instruction!)


#4

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