vars_names = []
for node in ast.walk(tree):
if not (isinstance(node, ast.FunctionDef)):
continue
for var in node.body:
if isinstance(var.value, ast.Name):
vars_names.append(var.value.id.lower())
print(vars_names)
AttributeError: 'For' object has no attribute 'value'