在Python中的N个自然数列表中查找缺失的数

时间:2019-07-13 18:41:13

标签: python list

找到N个自然数列表的缺失元素。 [第10和18行中的错误] [“ int”对象不可调用]

numTest = int(input(""))
n = 1
while n <= numTest:
    numEle = int(input(""))

    numEleList = list(map(int, input("").split()))


    def fun(numEleList, numEle):
        sumReq = int((numEle(numEle + 1)) / 2)
        sumGiven = sum(numEleList)

        reqNum = sumReq - sumGiven

        return reqNum


    print(fun(numEleList, numEle))

    n += 1

1 个答案:

答案 0 :(得分:0)

您忘记了*

line 10: numEle * (numEle + 1) / 2