-1
我需要在2个变量中生成10个随机数并计算它们之间的比率。 我的代码如下。我究竟做错了什么?不支持的操作数类型为/:'list'和'list'Python
from random import randint
N=10
a = [random.randint(0, 10) for _ in range(N)]
b = [random.randint(0, 10) for _ in range(N)]
print (a,b)
ratio = a/b
TypeError: unsupported operand type(s) for /: 'list' and 'list'
诊断似乎很清楚。 '/'运算符不接受类型列表的操作数。你想计算list * elements *对的商数,而不是列表本身的商数。 –