I am trying to write a function that takes a nested tuple of strings and returns another tuple that contains all items of the original one, but "unpacked".
For example:
my_hobbies = ('reading', ('jogging', 'boxing', 'yoga'), 'movies').
TO
my_hobbies_unpacked = ('reading', 'jogging', 'boxing', 'yoga', 'movies')
I wrote the function below to accomplish this, but I am still receiving feedback that my answer is incorrect, how can I improve?
def unpack(input_tuple):
mm = list(input_tuple)
for x in mm:
if isinstance(x, tuple):
for y in x:
mm.insert(-1,y)
mm.remove(x)
unpacked = tuple(mm)
return unpacked