"It's Not All Animals and Fruits" error. Help me get the mistake


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/learn-python/lessons/introduction-to-classes/exercises/its-not-all-animals-and-fruits

<In what way does your code behave incorrectly? Include ALL error messages.>
SCT error

<What do you expect to happen instead?>
Next

```python

class Animal(object):
""“Makes cute animals.”""
is_alive = True
health = "good"
def init(self, name, age):
self.name = name
self.age = age

Add your method here!

def description(self):
print self.name
print self.age

hippo = Animal(‘Anderson’, 36)
sloth = Animal(‘Dale’, 15)
ocelot = Animal(‘Fuzzy’, 7)

print hippo.health
print sloth.health
print ocelot.health

class ShoppingCart(object):
my_bill = {}
def init(my_cart, name):
my_cart.name = name

def add_item(my_cart, item, price):
my_bill[item] = price

my_cart = ShoppingCart(“Eric”)
my_cart.add_item(“Ukelele”, 10)

<do not remove the three backticks above>

#2

Hi @arcsolver96905,

How did the code regarding class Animal wind up in the submission for the “It’s Not All Animals and Fruits” exercise? That might not be the cause of the SCT error, nevertheless it should not be included in the current submission.


#3

Below the class of animal, I put class ShoppingCart
Because the class animal came by default, then I continued after it.
So, I didn’t remove the class Animal


#4

Even if I remove class animal, I get the same SCT error.
Here’s my code:

class ShoppingCart(object):
my_bill = {}

def init(my_cart, name):
my_cart.name = name

def add_item(my_cart, item, price):
my_bill[item] = price

my_cart = ShoppingCart(“Eric”)
my_cart.add_item(“Ukelele”, 10)


#5

The SCT error might be due to a bug in the system. However, there is still at least one issue to resolve regarding your code.

Have you edited the add_item method? It contains an invalid reference to my_bill. As you run your code, you may see that noted in the console window.

The original add_item method probably was as follows, and it may be best to restore it …

    def add_item(self, product, price):
        """Add product to the cart."""
        if not product in self.items_in_cart:
            self.items_in_cart[product] = price
            print product + " added."
        else:
            print product + " is already in the cart."

#6

The issue of the SCT error has been reported to Codecademy staff. If it is caused by a bug in the system, they will fix the problem.


#7

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