should be add : if checksum <0 ch = data[i]+1 # add this line checksum = checksum<<1 + che
should be add :
if checksum <0 ch = data[i]+1 # add this line
checksum = checksum<<1 + che