Page 1 of 1

3. Use recursive functions only Python only** listSequencesStartingWith - Given the same arguments as printSequencesStar

Posted: Sat May 14, 2022 8:24 pm
by answerhappygod
3. Use recursive functions only
Python only**
listSequencesStartingWith - Given the same arguments as printSequencesStartingWith, this function must return a list of strings containing all of the RNA sequences that that function would have printed. If the prefix provided is equal to or longer than the target length, a list containing just that prefix string is returned. These listSequencesStartingWith examples demonstrate how it should work.
Hints:
• In the base case, think first about type of value you need to return before figuring out the actual value.
• In the recursive case, you should call listSequencesStartingWith recursively exactly four times, once for each RNA base.
• Using append in this function is not recommended. Using the + operator to combine lists is likely a better approach.
Define listSequencesStartingWith with 2 parameters
Use def to define listSequencesStartingWith with 2 parameters
Use a return statement
Within the definition of listSequencesStartingWith with 2 parameters, use return _ in at least one place.
Call listSequencesStartingWith
Within the definition of listSequencesStartingWith with 2 parameters, call listSequencesStartingWith in at least one place.
In [ ]: listSequencesStartingWith(' ',1)
Out[ ]: ['A', 'C', 'G', 'U']