Я сейчас изучаю Python и не понимаю, что не так с моим кодом, но PyCharm продолжает выдавать мне следующую ошибку:
Traceback (most recent call last):
File "C:/Users/Sam/PycharmProjects/untitled1/app.py", line 5, in <module>
fish1.bubbles()
TypeError: bubbles() missing 1 required positional argument: 'self'
Вот мой код:
import random
from Fish import Fish
fish1 = Fish
fish1.bubbles()
fish1.name = input("enter the name of your fish: ")
fish1.coords = ("({0},{1})".format(random.randint(1, 100), random.randint(1, 100)))
print("The fish's name is {0}, and it is swimming at co-ordinates{1}".format(fish1.name, fish1.coords))
и вот мой файл Fish.py:
class Fish:
def __init__(self, name, coords):
self.name = name
self.coords = coords
def bubbles(self):
print("{0} blew some bubbles".format(self))
Буду признателен за любую помощь!