I'm very new to coding and need help on one last question of an assignment that has me stumped. I can't use regular expressions for this assignment, either.
I've got this string, and I've made it so I split the string after 'cat'
occurs.
astr = 'accaggcatgattgcccgattccatgcggtcag'
x = astr.split('cat',1)[-1]
print(x)
gattgcccgattccatgcggtcag
y = astr.split('cat',2)[-1]
print(y)
gcggtcag
However, what can I do if I only want the three letters after each 'cat'
in the string? For example, I'd want to get 'gat'
and 'gcg'
.
Any help is greatly appreciated!