Hello, I have an array that takes on the following form:
x = [1000,1001,1011,1111] The array elements are meant to be binary representation of integers. Goal: Access array elements and extract the first two bits. e.g. Final result would look something like this: x_new = [10,10,10,11] What I have tried: data_indices = range(4) # Set up array of values to loop over for idx in data_indices: f = x[idx] # Index into array of x values f_idx = f[:2] # Extract first two elements print f_idx I then receive the following error: IndexError: invalid index to scalar variable. Any help with accomplishing my outline dgoal would be greatly appreciated. Thank you. Colin _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor