Someone wrote in [community profile] intro_to_cs 2010-06-16 09:49 am (UTC)

python

Write the function subStringMatchExact. This function takes two arguments: a target string, and a key string. It should return a tuple of the starting points of matches of the key string in the target string, when indexing starts at 0. Complete the definition for

def subStringMatchExact(target,key):
For example,
subStringMatchExact("atgacatgcacaagtatgcat","atgc")
would return the tuple (5, 15).

Here are some test strings that you can use to test your function.
target1 = 'atgacatgcacaagtatgcat' target2 = 'atgaatgcatggatgtaaatgcag'
and four key strings:
key10 = 'a'
key11 = 'atg'
key12 = 'atgc'
key13 = 'atgca'



Test your function on each combination of key and target string, as well as other examples that you create.

Post a comment in response:

This community only allows commenting by members. You may comment here if you're a member of intro_to_cs.
(will be screened if not on Access List)
(will be screened if not on Access List)
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting