Question: Write a recursive function str2obj ects(spec) that creates a list of Python objects based on the contents of the string spec. 1 def str2objects(spec): 2

Write a recursive function str2obj ects(spec) that creates a list of Python objects based on the contents of the string spec. 1 def str2objects(spec): 2 >>>str2objects ("dict list str dict") Assume that spec contains only whitespace separated occurrences of "dict" "ist", and "st r" Your first thought might be to use a helper function or a default argument but perhaps the following will inspire another way to approach the problem: >>>"a b c".split (None, 1) l'a', 'b c' Programming Requirements Solve this problem using recursion. You are allowed to use only. the following programming constructs: . if statements; . return statements . assignment, recursive function calls (if you use any helper functions then these must all be recursive as well); comparison operations(, !, etc.) . list indexing and slicing, . list concatenation/extension The len () built-in function; The method st r.split)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
