python---1 发表于 2021-5-21 20:53:27

怎么改????,谢谢

def func(listinfo):
    try:
      result = filter(lambda k: k<100 and k%2==0, listinfo)
    except Exception as err:
      return err
    else:
      return list(result)

listinfo =
assert type(func(listinfo)) == list
assert func(listinfo) ==



要返回
Traceback (most recent call last):
File "C:/Users/Administrator/AppData/Local/Programs/Python/Python38/1.py", line 10, in <module>
    assert type(func(listinfo)) == list
AssertionError

怎么改????,谢谢

Twilight6 发表于 2021-5-21 21:05:16


参考代码:

def func(listinfo):
    try:
      result = filter(lambda k: k<100 and k%2==0, listinfo)
    except Exception as err:
      return err
    else:
      print(list(result))
      return False

listinfo =
assert func(listinfo)

python---1 发表于 2021-5-21 22:14:07

Traceback (most recent call last):
File "C:/Users/Administrator/AppData/Local/Programs/Python/Python38/1.py", line 11, in <module>
    assert func(listinfo)
AssertionError

terry_zxf 发表于 2021-5-22 00:00:27

def func(listinfo):
    try:
      result = filter(lambda k: k<100 and k%2==0, listinfo)
    except Exception as err:
      return err
    else:
      print(list(result))
      return True

listinfo =
assert func(listinfo)

python---1 发表于 2021-5-22 11:26:53

谢谢啦
页: [1]
查看完整版本: 怎么改????,谢谢