# Exercise in reversing bytes
# Providedby Anthony Vogelaar, Perth Scotland
# rev 0.10  2025-07-31  initial release

Z    = b'\x00\xc2\xe2\xb2\x9a\x8e\x86\x00'

def rev1(x):
    return bytes(reversed(x))


def rev2(x):
    lng  = len(x)
    Zrev = bytearray(lng)
    for i in range(lng):
        Zrev[i] = x[lng-1-i]
    return bytes(Zrev)


def rev3(x):
    idx = len(x) - 1
    res = []
    while True:
        res.append(x[idx])
        idx = idx - 1
        if idx < 0:
            break
    res = bytes(res)
    return res
    
    
print('Z    :', Z)
print('Zrev1:', rev1(Z))
print('Zrev2:', rev2(Z))
print('Zrev3:', rev3(Z))
