I am trying to do a left-byte shift on a list. But it is not working properly.
def left_byte_shift(w3):
temp = w3
x=0
a = (len(w3)-1)
print("a=",a)
for i in reversed(range(len(w3))):
if i == a: #3
w3[x] = temp[a]
else: #2,1,0
print(w3[i],temp[i+1])
w3[i] = temp[i+1]
print(w3[i],temp[i+1],'\n\n')
return w3
I think this is what you're looking for?
w = [1, 2, 3, 4]
w[-1], w[:-1] = w[0], w[1:]
print(w) # [2, 3, 4, 1]
It's not exactly a left "byte" shift, more like a left element shift.