'sum and len unsupported operand type(s) for +: 'int' and 'str

`list = []
with open("ads.txt", "r", encoding="UTF-8") as ads:
    first= ads.readline()
    for i in ads:
        i = i.strip().split(";")
        list.append(i)
    print(f"3.: aaa: {len(lista)} db")
    height = [i[2] for i in lista]
    print(f"4.: average: {sum(height)/len(height)}")`

TypeError: unsupported operand type(s) for +: 'int' and 'str can you help



Solution 1:[1]

agree with @Samwise, the list - height should contain numbers. the code is being stuck at sum(height)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 paulyang0125