I want the to directly populate particular sections of a list from a string that is returned by a function. I want to do some binary arithmetic on these elements later. When I access the list using subscript, the elements are not getting stored as I expect. A simplified version of my code is:
reg_bin_list = ['0']*2
reg_bin_list[0:1] = "10"
print reg_bin_list
This puts an extra zero at the end: ['1', '0', '0']
Instead of that if do :
reg_bin_list = "10"
Then the list is printed correctly as I expect i.e. ['1', '0']
Can anyone help me understand when I access using the index operator, what is going on. Why am I seeing an extra zero at the end?