If I run this code, I get segments starting from the beginning. I need this code for little-endian purposes so I have to reverse the order since I will be pushing bytes on the stack and the last bytes at the end are actuall first. The order is correct. The issue is that if I segment them by 8 bytes, it starts at the beginning. The last segment is not 8 bytes, it is 3 so I want to start from the end. Any ideas? import sys from textwrap import wrap string = sys.argv[1] data = string.encode().hex() value=bytes.fromhex(data) value=value[::-1] s = bytes.hex(value) #print(s) print(wrap(s, width=8)) To run it, its just python3 this_script.py "this is a long string". Currently, the output looks like this: ['676e6972', '74732067', '6e6f6c20', '61207369', '20736968', '74'] I want it to start at the end, from 74. Here is what I would like output to look like. ['67', '6e697274', '7320676e', '6f6c2061', '20736920', '73696874'] Continue reading...