你print(list)干吗,print(factor(a))啊不然得先赋值(list = factor(a),建议别用list,会覆盖列表list)
print(factor(a))
因为它是一个局部变量,只在函数内部起作用,你函数外部调用就报错了,要定义变量接收
list=factor(a)