Python Land › Forums › The Python Tutorial › Classes and Objects in Python › Reply To: Classes and Objects in Python
February 22, 2021 at 1:10 pm
#1897

Moderator
Yes I think that’s exactly what’s happening. I see the page got updated to explicitly tell you to hit enter twice after pasting the class. Only after that, you can create a car object.
So first copy-paste this:
class Car:
speed = 0
started = False
def start(self):
self.started = True
print("Car started, let's ride!")
def increase_speed(self, delta):
if self.started:
self.speed = self.speed + delta
print('Vrooooom!')
else:
print("You need to start the car first")
def stop(self):
self.speed = 0
print('Halting')
car = Car()
And hit enter twice. Then you can use the class, e.g. with car = Car()