I am supposed to split this sequence into the list of n=3.
# result = ['agu','cac','cgu','cau']
# 'tc' is supposed to be ignored as it doesn't equal to n=3
I have tried the below code:
"""This functions returns a list of codons present in an RNA sequence"""
# store the length of string
length = len(RNA)
#divide the string in n equal parts
n = 3
temp = 0
chars = int(len(RNA)/3)
#stores the array of string
change = 
#check whether a string can be divided into n equal parts
for i in range(0, length, chars):
part = [RNA[i:i+3] for i in range(0, length, n)];
if (length % n != 0):
But when I try to run my previous code again, it still returns the 'tc'
# result = ['agu', 'cac', 'cgu', 'cau', 'tc']
Should I do to ignore the chars that are not equal to n=3 or my last part of the 'tc'?