On Jan 30, 8:20 pm, uche <uraniumore...@gmail.com> wrote: > Another issue: > x[a], x[b] = x[(a)] + W[(n % N)] * x[(b)], x[(a)] - W[(n % N)] * x > [(b)] > TypeError: can't multiply sequence by non-int of type 'complex'
With your original code, the elements of array2 are strings, and here Python is refusing to multiply the string x[a] by the complex number W [n % N]. Presumably you want the elements of array2 to be integers or floats instead? (Your comments suggest integers, though I think floats would be more natural here.) MRAB's earlier reply suggests how to fix this: array2 = [] for a in range(len(array)): array2.append(int(array[a])) # note the extra int! That works, but the code is cleaner if you iterate over the elements of the array directly, instead of over their indices: array2 = [] for x in array: array2.append(int(x)) There are other ways, too: a seasoned Python user would probably write this either as a list comprehension: array2 = [int(x) for x in array] ... or using the built-in map function: array2 = map(int, array) -- Mark -- http://mail.python.org/mailman/listinfo/python-list