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) for i in [0..n-1]) ksi = e^(2*pi*I/n) chi(x)=ksi^(tr(x)) for a in k: L_a = [chi(a*x) for x in k] print L_a
And the TypeError is "free variable 'x' referenced before assignment in enclosing scope". Can somebody help me how to fix the code?