Search in depth, how to output the contents of the stack? Python

It is necessary to write an algorithm for traversing the graph by searching in depth, output the current vertex, DFS number, stack content, I can not figure out how to implement the stack.

def dfs(v):
    global Edges, number,stack
    visited[v] == True 
    stack.add(v)
    number+=1
    print('Вершина: ',v,'DFS-номер: ',number, "Stack",stack)
    for key in Edges[v]:
        if visited[key] == False:   

            dfs(key)
        elif visited[key] == True:
            stack.remove(key)


stack = set()
number = 0
Vertex  = 0
Vertexs = []
Edge = 0
f = open("Text.txt", 'r')
with f:
    Vertexs = [ line.split() for line in f ]    
    Vertex = Vertexs[0][0]
    Edge = Vertexs[0][1]
    del Vertexs[0]
print("Ребра графу: ",Vertexs)
Edges = {}
for i in range(int(Vertex)):
    Edges[i+1] = []

for i in range(int(Vertex)):
    for elem in Vertexs:
        if int(elem[0]) == i+1:
            Edges[i+1].append(int(elem[1]))
print("Список суміжніх вершин: ", Edges)
visited = [False] * (int(Vertex)+1)

dfs(1)

I can't figure out why vertices aren't removed from the stack if they don't already have adjacent vertices.

Author: VladilsavOl, 2020-05-07