I made a recursive function which takes a binary code and is supposed to convert to the letters "A", "T", "C" and "G".
Then in this, it's supposed to assign that binary code to the corresponding letters below, but it just doesn't move past the first letter. Can any of you guys help me sort this out?
def numeros(i,f):
e="100101"
if i >=len(e):
print f
else:
if e[i:i+1]=="1":
f=f+"G"
print f
numeros(i+1,f)
elif e[i:i+3]=="011":
f=f+"T"
print f
numeros( i+3,f)
elif e[i:i+3]=="010":
f=f+"A"
print f
numeros( i+3,f)
elif e[i:i+3]=="00":
f=f+"C"
print f
numeros( i+3,f)
numeros(0,"")
elif e[i:i+2] == '00':and in the subsequent callnumeros(i+2, f). It's also not necessary to do recursively. It can be done with the same logic iteratively. You're effectively decoding a prefix code.