There is a predefined variable code that contains the source code. Write a program that will traverse the tree and print the name of each Import. Each name should be on a new line.
For example, if the code in the code variable looked like this:
import random
import time
print("Welcome to the Random Number Generator!")
for _ in range(10):
random_number = random.randint(1, 10)
print(f"Random number is: {random_number}")
time.sleep(2)
the result of the program should be as follows:
random
time
Tip: You can solve the problem however it is most convenient to you but, in case you're going to use ast.NodeVisitor class, keep in mind that Import node class has names attribute which is a list of alias nodes. To access their actual names, just refer to their name attribute.