Calling a class method raises a TypeError in Python

前端 未结 8 665
小鲜肉
小鲜肉 2020-12-04 16:02

I don\'t understand how classes are used. The following code gives me an error when I try to use the class.

class MyStuff:
    def average(a, b, c): # Get th         


        
8条回答
  •  难免孤独
    2020-12-04 16:38

    You never created an instance.

    You've defined average as an instance method, thus, in order to use average you need to create an instance first.

提交回复
热议问题