我不知道如何解决此错误,python3语法错误“ def”

-2 python function syntax-error python-3.x

我想解决这个错误。我尝试了近半小时,但找不到答案。

这是我的错误

 File "sampling_fun.py", line 71
    def average(self) :
      ^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)

和完整的代码

import csv

class fun :
    def __init__(self, rowList, num) :
        list = []
        listLen = len(self.rowlist)-1
        for i in range(listLen) :
            list.append(self.rowList[i+1][num]  # num = Header 1~4

    def average(self) :
        ave = sum(self.list)/self.lestLen
        print("average : %0.2f" %ave)
        return ave

testlist = cssRead('Data_2', 1)
test1 = fun(testlist, 1)
test1.average()
Run Code Online (Sandbox Code Playgroud)

Sio*_*Goh 5

遇到此类错误时,请检查它之前的行。

您有一个不匹配的括号,缺少追加的右括号。

list.append(self.rowList[i+1][num])
Run Code Online (Sandbox Code Playgroud)