Advertisement
janoulle

Jane / Problem Set 3 - A from MIT OCW Intro to Computer Science course

Jan 14th, 2011
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. target1 = 'atgacatgcacaagtatgcat'
  2. target2 = 'atgaatgcatggatgtaaatgcag'
  3. testtarget = 'atgaatgcatggatgtaaat'
  4.  
  5. # key strings
  6.  
  7. key10 = 'a'
  8. key11 = 'atg'
  9. key12 = 'atgc'
  10. key13 = 'atgca'
  11.  
  12.    
  13. def recursivematch(target,key,pos):
  14.     '''Recursive Function to Print Out Index at Which Key is found.'''
  15.     index = target.find(key,pos)
  16.     keylen = len(key)
  17.     if index == -1:
  18.         print('Loop has ended')
  19.         return None
  20.     else:
  21.         print('Index is {0}'.format(index))
  22.         index += keylen
  23.         return recursivematch(target,key,index)
  24.  
  25. x = 0
  26. recursivematch(target2,key12,x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement