5/11-6/11 Says its wrong, still accepts it but later won't


#1

class Car(object):
condition = "new"

my_car = Car(self, model, color, mpg)
self.model = model
self.color = color
self.mpg = mpg
model = "DeLorean"
color = "silver"
mpg = 88
print my_car.condition
print my_car.model
print my_car.color
print my_car.mpg


#2

Hi @everyusernameistaken,

First, a little trick: See this thread for a trick to paste your code in the forum and have it remain indented and formatted!

Now on to your code... You are missing an important part: You are not defining the __init__() function anywhere, as prescribed in the instructions and that is why you are running into problems.

Here's an example of what your code should look like:

class Ticket(object):
    printable = "yes"
    def __init__(self, transport, valid, price):
        self.transport = transport
        self.valid = valid
        self.price = price

my_ticket = Ticket("Bus", "3 days", 16)

print my_ticket.printable
print my_ticket.transport
print my_ticket.valid
print my_ticket.price

Now read the instructions again and see the hint of 5/11 and you should be well on your way to the next exercise!

Good luck! :smile:


#3

This helped out, thanks denisaltroy


#4

my code is this solve me...!

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


#5

Hey there dataace,
The problem you have is with your following line:

def init(self, model, color, mpg):

To get your code to properly work you'll need to add two under-scores ( __ ) to the front and end of init so it'll look like this: def init(self, model, color, mpg):