FAQ: Learn Python - Introduction to Bitwise Operators - Class Syntax

This community-built FAQ covers the “Class Syntax” exercise in Codecademy’s lessons on Python.

FAQs for the Codecademy Python exercise Class Syntax:

Join the Discussion. We Want to Hear From You!

Have a new question or can answer someone else’s? Reply (reply) to an existing thread!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources about Python in general? Go here!

Want to take the conversation in a totally different direction? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account, billing, Pro, or Pro Intensive? Reach out to our support team!

None of the above? Find out where to ask other questions here!

Other FAQs

The following are links to additional questions that our community has asked about this exercise:

  • This list will contain other frequently asked questions that aren’t quite as popular as the ones above.
  • Currently there have not been enough questions asked and answered about this exercise to populate this FAQ section.
  • This FAQ is built and maintained by you, the Codecademy community – help yourself and other learners like you by contributing!

Not seeing your question? It may still have been asked before – try searching for it by clicking the spyglass icon (search) in the top-right of this page. Still can’t find it? Ask it below by hitting the reply button below this post (reply).

I am trying to solve the exercise, but I am having a hard time trying to understand where is the class’ body. Is it where the “class magic” is going to happen? I have been trying to place the “pass” keyword in different places, but all of them gives an error

If I were to define a class called, Pizza…

class Pizza:
    pass
    #inside the body

#outside the body

There is no need for the parenthesis in this case?

Edit 1: " Make sure your Animal class inherits from the object class. " -> It gives the following error if I follow the upper code". Same error if I put the parenthesis. I literally don’t know what synthax to follow for this exercise, as everything seems to do an error

No. Classes do not take parameters. What you need is the proper syntax for inheritance. If Pizza were a class that inherited some of its attributes from a base class called Pie for example:

class Pizza(Pie): #because this is a class and not a function, Pie is the base class that pizza inherits from rather than a parameter
    pass

If this isn’t working for you, please include your code, and a link to the specific exercise.

class Animal():

  pass

This has been my current code.

The link to the excercise I am doing is this one: https://www.codecademy.com/courses/learn-python/lessons/introduction-to-classes/exercises/class-syntax

I just started looking into classes in python so I am very unfamiliar with it. I still haven’t learn what inheritance is exactly. That’s why I am having a hard time in this synthax.

Edit 1: By the way, if I put something into where an object should go, ffor instance:
class Animal(Lion):
pass

it will give me the following error:
Traceback (most recent call last):
File “python”, line 1, in
TypeError: Error when calling the metaclass bases
int() takes at most 2 arguments (3 given)

Okay. I’ve looked at the lesson. What it wants is for you to use the object class specifically.

class Animal(object):
  pass

This should allow you to proceed.

Also, notice how your code appears now compared to when you posted it. Please review How do I format code in my posts? Following these guidelines will allow code you post to retain its original formatting.

Happy coding!