После этого мой код выглядел так:
Код: Выделить всё
def construct_path_using_dict(previous_nodes, end_node):
constructed_path = []
current_node = end_node
while current_node:
constructed_path.append(current_node)
current_node = previous_nodes[current_node]
constructed_path = reverse(constructed_path)
return constructed_path
Почему это было сделано Сюда?
Разве не имеет смысла иметь возможность возвращать перевернутый список напрямую, без предварительного выполнения list.reverse() или list =verse(list) ?
Подробнее здесь: https://stackoverflow.com/questions/649 ... st-reverse
Мобильная версия