grade=['Ben Anderson',95,90,100,-1,'Mary Johnson',75,78,79,-5,'Michael Walter',80,68,0]
def convert_grades(lst):
a = []
b = []
for i in lst:
if isinstance(i,str):
c = 0
while lst[c] < 0 or lst[c] == []:
a = a + lst[c]
c = c + 1
b = b + a
return b
我希望它返回
[['Ben Anderson',95,90,100],['Mary Johnson',75,78,79],['Michael Walter',80,68,0]]
但它返回为[]
我不知道发生了什么事。需要帮助。