I tried to make a checksum function but my tests returned None
instead of the expected output. Can you point out where I went wrong and how to correct it? I am trying to get a numerical sum out of a bunch of strings in the test code.
def string_checksum(data):
partialchecksum = 0
for i in data:
if i is int:
partialchecksum += i
else:
def tobits(i):
result = []
strsum = 0
for c in i:
bits = bin(ord(c))[2:]
bits = '00000000'[len(bits):] + bits
result.extend([int(b) for b in bits])
strsum = sum(result)
checksum = partialchecksum + strsum
return checksum
## Heading ##