Discuss / Python / 为什么提示TypeError: unsupported operand type(s) for /: 'list' and 'int'?

为什么提示TypeError: unsupported operand type(s) for /: 'list' and 'int'?

Topic source

import math def quadratic(a,b,c): if b^2 - 4ac > 0: x1 = [-b + math.sqrt(b^2-4ac)]/(2a) x2 = [-b - math.sqrt(b^2-4ac)]/(2a) return x1,x2 elif b^2 - 4ac == 0: x1 = x2 = (-b)/(2*a) return x1 else: return 3.6.3版本的Python IDLE,请问廖老师是我哪里做错了吗?

查了网上的,好像是不能用中括号,我把中括号改成小括号就可以运行了,但是答案是错的(lll¬ω¬)


  • 1

Reply