pip install code2flow
python
import code2flow
python
with open('example.py', 'r') as file:
code = file.read()
block_map, start_label, end_label = code2flow.flowchart_text(code)
diagram = code2flow.flowchart_code(code, block_map, start_label, end_label)
diagram.save("flowchart.png")
python
def calculate_average(numbers):
total = 0
count = 0
for num in numbers:
total += num
count += 1
average = total / count
return average
python
diagram = code2flow.flowchart_code(code, block_map, start_label, end_label, vertical=True, highlight_lines=[5, 8])