I am trying to change the contents of a list changing every -127 for a 1 and -128 for a 0. However I struggle to find why my code does not change the digits as intended or even recognizes them:
my_file = open("log.txt", "r")
content = my_file.read()
my_file.close()
clean_contnet = content.split("\n")
for idx, x in enumerate(clean_contnet):
     if x == -127 or x == -128:
        if x == -127:
            clean_contnet[idx] = 1
        else:
            clean_contnet[idx] = 0
     else:
        print("no -127 or -128 detected")
print(clean_contnet)
The (shortened) contents of 'log.txt' are as follows
0 -127 1 -128 0 -127 1 -128 0 -127 1
 
     
    