def countSubStringMatchRecursive(target, key, x): x = find(target, key, x) if x == -1: return 0 else: return countSubStringMatchRecursive(target, key, x+1) +1 target = ["atgacatgcacaagtatgcat", "atgaatgcatggatgtaaatgcag"] key = ["a", "atg", "atgc", "atgca"] for t in target: for k in key: print "There were " + str(countSubStringMatchRecursive(t, k, 0)) + " occurances of your key " + k + " in " + t |
Highlighted in yellow is what are called ‘lists’. Lists are good for collecting and manipulating data. There are TONS of ways to interact with lists, you can view more at python.org. We all like them, lists are very usable in everyday life. However in order to interact with them in Python there are many different options given.
One of the interesting things about lists is the fact that you can manipulate them. In other words, you can adjust what’s inside them. There are other things that are not mutable (changeable), such as tuples.
Above I have two lists; target, and key. Lists in python can be written with this syntax. The name is placed on the left, then an equals sign (also known as the assignment), brackets and then each item in the list is separated with a comma.
listname = [item1, item2, item3] |