I’ve been following tutorials on python and came across a problem:
def middle(L):
calc1 = (len(L))//2
print(L[calc1])
return
and the grader/compiler gave me
“Running middle([8, 0, 100, 12, 1]) … Error: middle([8, 0, 100, 12,
1]) has wrong type “None” Type, expected Integer”
what i have to do is print() an element that is in the middle of a list. Although it did output a 100.
The solution must be so simple, but i’ve just started learning python, let alone coding.
You’re printing the value but not returning it. No idea what your calling code is doing but it’s clearly expecting you to do
return L[calc1].