15. median - what's wrong with my code


#1

When I run my code I'm getting an error:
median([1]) resulted in an error: can only concatenate list (not "int") to list

I found solutions on the forum but can you tell me what is wrong with my code?


def median(lista):
    lista.sort()
    x=len(lista)
    mediana=x/2
    if x%2==0:
        index=lista[mediana] + lista[mediana-1]
        wynik=index/2.0
    else:
        index=len(lista+1)
        wynik=index/2.0
    return wynik
lista_a=[1,2,3,4,5,6]
print median(lista_a)


#2

May be written as,

    wynik = lista[mediana]