I am trying to write a code to calculate the average of the height of the student
that is my code
height = input("what is your higth\n").split()
for n in range(0, len(height)):
height[n] = int(height[n])
print(height)
t = 0
for i in height:
t += height
print(height)
and I have error
t += higths
TypeError: unsupported operand type(s) for +=: 'int' and 'list'
>Solution :
Use enumerate on the for loop to access to the list indexes and convert it to int.
Then calculate the sum divided by the len of the list.
height = input("what is your higth\n").split()
for i, element in enumerate(height) :
height[i] = int(element)
# Average
print(sum(height)/len(height))