A number of things are going on there, so we'll take a moment and talk about them.
First, we used the class
command to create a new class called World
.
class World:
In Python, code is grouped by using indentation. In order to tell Python we're starting a new group of indented code we end the line with a colon. We can't just throw colons where ever we want, though. They need to follow specific commands. We'll see more uses of colons as we continue coding.
Next, we defined a method with the def
command and called it __init__
.
def __init__(self):
A method is a function that belongs to a class. To better understand what a method is, we need to talk about functions.
Essentially, a function is just a block of code that is given a name. Later on, we can call the function by name and all the code in it...