Question: IN PYTHON 3 LANGUAGE Define a recursive function named my_str; it is passed an int or list whose elements are ints or lists of ints,
IN PYTHON 3 LANGUAGE
Define a recursive function named my_str; it is passed an int or list whose elements are ints or lists of ints, or lists of lists of ints, etc. It returns a string: the same string that str returns when called on such an argument (but, of course, you cannot call str or __str__ etc. You must write your own recursive my_str function that solves this problem). my_str must deal with references inside the list that refer to the list. For example, if we wrote x = [1,1] and then x[1] = x the following structure results.

Sample output:
x = [1,[2],3]
x[1] = x
my_str(x) == str(x) #returns '[1, [...], 3]'
x = [1,2,3]
x[1] = x
y = [10,11,12]
x[0] = y
y[2] = x
my_str(x)==str(x) #returns '[[10, 11, [...]], [...], 3]'
my_str(y)==str(y) #returns '[10, 11, [[...], [...], 3]]'
list str (x) returns [1, [...11; my str(x) should return the same. In a recursive call, when asked to convert a list that is already being converted immediately return [...1. int
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
