The func count

Report a typo

There is a predefined variable code that contains the source code. Print a list of the functions called in it. The output should be in the format: ['function', 'function']

For example, if the code in the code variable looked like this:

number = input()
print(pow(number, 2))

the result of the program should be as follows:

['input', 'print', 'pow']

After parsing the source code, use the ast.walk method to get the right order of the functions.

Tip: Find all nodes of the ast.Call class and save their names to a list with the node.func.id attribute. You can check whether a node belongs to some class this way: isinstance(node, ast.Class).

Write a program in Python 3
import ast

# put your code here
___

Create a free account to access the full topic