The python code in the challenge text is the program used to encode the original flag. It is the program that we need to reverse.
The program shifts the bits for every other letter of the flag left by 8 bits (1 byte). Then, it adds the next latter of the flag to the shifted value. In other words, each letter is represented as a byte and they are joined together in pairs of two.
We can reverse this (see script.py) by looping through the encoded flag and for each loop we:
Shift the bits right to get the first letter in the pair.
Convert the encoded character to bytes and get the last byte to get the second letter in the pair.