Help would be greatly appreciated with this as Im struggling with the final product.
I need to write a function that opens and reads the file, returns a dictionary where each key is the name of a function, and the value is a list of the parameters of the function. And should return something like this.
{"h":[x], "f":[a, b], "g":[c]}
The file I am transferring looks like this
def h(x):
f(x + 4, 9)
def f(a, b):
e = a * b
g(e)
def g(c):
b = 3
print(c)
print(b)
So far my code looks like this but I have no clue how to make it look like the final product in dictionary.
filename=""
ddd=dict()
new=list()
def take_name():
global filename
filename= input("Please, type the name of the file:")
print(take_name())
def open_read():
global handle
handle= open(filename, 'r')
for line in handle:
line=line.rstrip()
if line.startswith('def'):
line=line.replace('def', " ")
line=line.replace(':', " ")
new.append(line)
print(new)
print(ddd)
print(open_read())
Thanks again for the help