我正在做作业,需要使用sum()和len()函数来计算输入数字列表的平均值,但当我尝试使用sum()函数来获取列表的总和时,出现了错误TypeError: unsupported operand type(s) for +: 'int' and 'str'。以下是我的代码:
numlist = input("Enter a list of number separated by commas: ")
numlist = numlist.split(",")
s = sum(numlist)
l = len(numlist)
m = float(s/l)
print("mean:",m)