Doctor is currently cleaning the computer that contain's all of Rhode Island patient's data, but the files are hidden so deep no one but you can retrieve it and help Doctor organize them again.
Your task now is to traverse the file tree and retrieve them in a special order called "PreOrder". By that order means that you have to print out the name of the folder first before going in to its content.
For example:
Doctor need to give this list to Kal'tsit - Doctor's boss, so your code MUST abide by this code template, and the function gen
MUST also be a generator function, meaning that it can only use yield
statement to return value.
genVar = gen(literal_eval(input()))
while True:
try:
print(next(genVar))
except StopIteration:
break
Hint: Use yield from
to yield recursively.
Complete the function gen
with the template code.
Generate the list in "Preoder" order.