Mar-02-2019, 05:19 PM
Hello Python Experts
Below code works without any issues when i called it though class method BUT when i called it through instance method , it is not working , may i please know why?
Working Code
Below code works without any issues when i called it though class method BUT when i called it through instance method , it is not working , may i please know why?
Working Code
class Pizza: def __init__(self, size): self.size = size def get_size(self): return "Size={}".format(self.size) print(Pizza.get_size(Pizza(4555))
Output:==> Size=4555
Error Codeclass Pizza: def __init__(self, size): self.size = size def get_size(self, data): return "Size={}".format(self.size) print(Pizza.get_size(4555))
Error:aankrose@PS1:~/code$ python3 phase2.py
Traceback (most recent call last):
File "phase2.py", line 7, in <module>
print(Pizza.get_size(4555))
TypeError: get_size() missing 1 required positional argument: 'data'