### character table of a finite field

I am trying to calculate the character table of a finite field. The following is my code:

```
def character_table(q,n):
k=GF(q^n)
```~~tr(x)=sum[(x^(q^i) ~~ tr(x)=sum(x^(q^i) for i in ~~[0..n-1])]
L=[tr(x) for x in K]
~~[0..n-1])
ksi = e^(2*pi*I/n)
chi(x)=ksi^(tr(x))
for a in ~~K:
~~k:
L_a = [chi(a*x) for x in ~~K]
~~k]
print L_a

And the TypeError is ~~'function' object has no attribute '__getitem__'. ~~"free variable 'x' referenced before assignment in enclosing scope". Can somebody help me how to fix the code?

Thanks

Blockquote