I have a DNA sequence:
seq='AACGTTCAA'
I want to count how many letters are equal to the next one. In this example I should get 3 (because of AA-TT-AA).
In my first try I found out that this doesn't work, because i is a string and 1 an integer.
seq='AACGTTCAA'
count=[]
for i in seq:
if i == i+1: #neither i+=1
count.append(True)
else: count.append(False)
print(sum(count))
So I tried this:
seq='AACGTTCAA'
count=[]
for i in seq:
if i == seq[seq.index(i)+1]:
count.append(True)
else: count.append(False)
print(sum(count))
Then I receive this output which I cannot understand. 3 of these True should be False (1,5,8) Especially 8 as it is the last element of the string.
6
[True, True, False, False, True, True, False, True, True]
If thought about doing this with arrays but I think there might be a easy way to do this just in strings. Thanks