def dup_add_term(f, c, i, K):
 if (not c):
  return f
 n = len(f)
 m = ((n - i) - 1)
 if (i == (n - 1)):
  return dup_strip(([(f[0] + c)] + f[1:]))
 elif (i >= n):
  return (([c] + ([K.zero] * (i - n))) + f)
 else:
  return ((f[:m] + [(f[m] + c)]) + f[(m + 1):])

def dup_add_term ( f , c , i , K ) : if ( not c ) : return f n = len ( f ) m = ( ( n - i ) - 1 ) if ( i == ( n - 1 ) ) : return dup_strip ( ( [ ( f [ 0 ] + c ) ] + f [ 1 : ] ) ) elif ( i >= n ) : return ( ( [ c ] + ( [ K . zero ] * ( i - n ) ) ) + f ) else : return ( ( f [ : m ] + [ ( f [ m ] + c ) ] ) + f [ ( m + 1 ) : ] )
add c*x**i to f in k[x] .