The code below takes dna_string2 and matches it within dna_string1. It then outputs the index location of the match or matches and then increments then return value by 1 to simulate "counting itself". The problem I am facing is that I need the output values of 2, 4, and 10 to be assigned to their own variables. I cannot figure out how to separate the output so that I can assign to individual variables. I have tried using split(). I have tried writing to a file first. I feel like I have tried just about everything to get the output separated. Any expert help would be greatly appreciated.
defined function
def get_most_likely_ancestor(dna_string1, dna_string2):
i = 0
g = len(dna_string2)
for i in range (len(dna_string1)):
i += 1
g += 1
if (dna_string1[i:g]) == (dna_string2):
locations = dna_string1.index(dna_string2, i)
locations += 1
return locations
Function input
dna_string1 = "GATATATGCATATACTT"
dna_string2 = "ATAT"
function output (exactly as shown)
2
4
10