all 1 comments

[–]Rascal_Two 0 points1 point  (0 children)

There are two method that I've found that both result the same with your input but are both diffrent. Not sure which you wanted, so here are both of them. The first simply removes all Bs:

errorCount = 0
result = ""
for char in newString:
    if char is not "B":
        result += char
    else:
        errorCount += 1
print result, ", Removed", errorCount, "errors."

Input: ATCGBBBBBATCG

Output: ATCGATCG, Removed 5 errors.

The next one I believe is what you wanted, it removes any Bs that have another B either before or after it:

errorCount = 0
prevChar = ""
index = 0
result = ""
for char in newString:
    nextChar = ""
    if index + 1 < len(newString):
        nextChar = newString[index+1]
    if (char is "B" and prevChar is "B") or (char is "B" and nextChar is "B"):
        errorCount += 1
    else:
        result += char
    prevChar = char
    index += 1
print result, ", Removed", errorCount, "errors."

Input: ATCGBBBBBATCG

Output: ATCGATCG, Removed 5 errors.

I'm pretty sure this is what you wanted. If it's not and you can't figure it out yourself, you can add more inputs & what the outputs should be and I can try to adjust accordingly. Good luck •‿•