How can I make an instance of a class?

Question

How can I make an instance of a class?

Answer

In Python we can create an object from a class by writing the basic structure: my_object = ClassName("parameters_if_any").
Be sure to put this outside your class, otherwise it will be considered part of the class code block and will not execute when you press Run. It should have no indentation before it.

3 Likes