From be16a1ef9ba376e11e445873bead55040531090a Mon Sep 17 00:00:00 2001 From: "Ajmera, Mahita SI/HZR-IDSA" Date: Thu, 17 Oct 2024 11:57:41 +0200 Subject: [PATCH] changing end character in print statement --- graphs/graphs_floyd_warshall.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/graphs/graphs_floyd_warshall.py b/graphs/graphs_floyd_warshall.py index 629da37af..c8d8315a2 100644 --- a/graphs/graphs_floyd_warshall.py +++ b/graphs/graphs_floyd_warshall.py @@ -9,10 +9,11 @@ def _print_dist(dist, v): print("The shortest path matrix using Floyd Warshall algorithm\n") for i in range(v): for j in range(v): + end_char = "" if j == v - 1 else "\t" if dist[i][j] != float("inf"): - print(int(dist[i][j]), end=" ") + print(int(dist[i][j]), end=end_char) else: - print("INF", end=" ") + print("INF", end=end_char) print() @@ -47,9 +48,9 @@ def floyd_warshall(graph, v): >>> dist, _ = floyd_warshall(graph, 3) The shortest path matrix using Floyd Warshall algorithm - 0 3 INF - 2 0 INF - 9 7 0 + 0 3 INF + 2 0 INF + 9 7 0 >>> dist == expected True """