I\'m having trouble with a homework problem. After I execute, I need to the resu
ID: 3620214 • Letter: I
Question
I'm having trouble with a homework problem. After I execute, I need to the result to look like this:>>> findLongestMatch()
Enter target sequence: ACGTACGTGTTATATCGATCGATGTACACAATCGG
Enter search sequence: ATCGTAGATCGAT
Found sequence ATCG starting at position 13
I'm given a code. I need to fill in where there is __________:
def findLongestMatch():
target = raw_input("Enter target sequence: ")
toFind = raw_input("Enter search sequence: ")
i = len(toFind)
while string.find(target, _______) == _______:
i = i - 1
print "Found sequence", _______, "starting at position", string.find(target, _______)
The concept of a while statment is very new to me, and I'm a little shaky on it. Also, I'm unsure on how to get the search sequence to decrease until it finds the longest match available. Can someone give me some insight on how to get started or help in general?
Explanation / Answer
Parameters:
Here is the detail of parameters:
str: specifies the string to be searched.
start: starting index, by default its 0
end: ending index, by default it’s equal to the length of the string.
Return Value:
It returns index if found and -1 otherwise.
str.find (sub [, start [, end]])
Return the lowest index in the string where substring sub is found, such that sub is contained in the slice s[start: end]. Optional arguments start and end are interpreted as in slice notation. Return -1 if sub is not found
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.