I am slicing 24 digits long binary number into three 8digits long numbers. Here is my code below:
def extract_number(number):
number_in_string = str(number)
red = number_in_string[:8]
green = number_in_string[8:16]
blue = number_in_string[16:24]
return [int(red), int(green), int(blue)]
if __name__ == '__main__':
print(extract_number(101111010110011011100100))
The result i get from the terminal is
[10111101, 1100110, 11100100]
The problem occurs in the 2nd number. It's digit is not 8 digits long when I did number_in_string[8:16]. And I using slice function wrong here?