Python Lesson
At this point you’re asked to create a function with two inputs. We’ll, after reviewing my work I realized that I reworked the answer to this function into another function that worked more appropriately to solve steps 3 and 4. Here I was supposed to create a function that would, based on two inputs, create a list of all the starting points where a key would show up in the string. I remembering creating that output, but then moving on in the problem anyways. So, instead, I’ll show you the next function in my Problem Set.
This next function I created was to solve one problem, it was to create a list of the prefixes and suffixes for whichever key is indicated.
Here I start with two variables, “x” and “z”. “Z” represents the position in the key where we are currently starting our slice from. “X” is the countdown, where the total amount to count up to is dependent upon the length of the key. For key “atgca”, its total length it 5. Then I create the list of prefixes and suffixes and call it “finallist”.
Next step is a while loop, where I indicate as long as the total value of x is less than the total length of the key provided, you continue to do the following actions. Those actions are first: using slices to create all the different prefixes and suffixes that occur for that particular key; then: for each pair of prefix and suffixes, you append them to your “finallist”. For each run through the while loop, there is a z+1 in the suffix creation. That means, that the suffix starts one after the prefix ended, so that we can create a function that allows for misspellings. It also allows for the function to continuously go through the list until there are no longer any letter to slice.
Creating this function took much longer, and was one of the longer hangups during this Problem Set, because I had never interacted with slices before. A slice, is a python term for taking/using only a part of a string. To indicate where you wish your starting point to be, you must simply say what position to start at (position number being 0 through however long your string is). I’ve a better understanding of slices now, and that help a bundle during the next couple of functions.