Is there a way to perform the following in a non-recursive fashion:
my_list = [
"level 1-1",
"level 1-2",
"level 1-3",
[
"level 2-1",
"level 2-2",
"level 2-3",
[
"level 3-1",
"level 3-2"
]
],
"level 1-4",
"level 1-5"
]
def print_list(the_list, indent_level=0):
for item in the_list:
if isinstance(item, list):
print_list(item, indent_level + 1)
else:
print "\t" * indent_level, item
print_list(my_list)