class Bike:
def __init__(self, speed):
self.speed = speed
def speed(self):
if (self.speed) > 120:
print("You are driving fast.")
else:
print("You are diving safely.")
bike1 = Bike(32)
bike1.speed()
It is showing:
Traceback (most recent call last):
File "C:\Users\Syed\PycharmProjects\Muneer Python\Python Beginner Mosh\App.py", line 10, in <module>
bike1.speed()
TypeError: 'int' object is not callable
I tried using a variable x
as self.speed
in speed
function, but still it is not working. How to fix it?