I have this function that takes in a 2d array, and returns a string. the string is supposed to have columns, where each column is a list from the 2d array. for some reason, something goes wrong when printing the middle 3 lists, and i cant figure out why. does anyone know what is wrong?
def printFancyNetwork(self) -> None:
temp_network: list = self.network
to_be_printed: str = ""
while True:
total_empty: int = 0
for layer in temp_network:
if len(layer) != 0:
to_be_printed += f"{layer[0]} "
layer.pop(0)
else:
total_empty += 1
to_be_printed += " "
to_be_printed += "n"
if total_empty == len(temp_network):
return to_be_printed
heres some test output where each block is an iteration in the for loop (except for the inital list and final string)
Inital: [[0.5, 0.5], [0.4, 0.4, 0.4], [0.4, 0.4, 0.4], [0.4, 0.4, 0.4], [0.3, 0.3, 0.3, 0.3]]
[[0.5], [0.4, 0.4, 0.4], [0.4, 0.4, 0.4], [0.4, 0.4, 0.4], [0.3, 0.3, 0.3, 0.3]]
[[0.5], [0.4, 0.4], [0.4, 0.4], [0.4, 0.4], [0.3, 0.3, 0.3, 0.3]]
[[0.5], [0.4], [0.4], [0.4], [0.3, 0.3, 0.3, 0.3]]
[[0.5], [], [], [], [0.3, 0.3, 0.3, 0.3]]
[[0.5], [], [], [], [0.3, 0.3, 0.3]]
[[], [], [], [], [0.3, 0.3, 0.3]]
[[], [], [], [], [0.3, 0.3, 0.3]]
[[], [], [], [], [0.3, 0.3, 0.3]]
[[], [], [], [], [0.3, 0.3, 0.3]]
[[], [], [], [], [0.3, 0.3]]
[[], [], [], [], [0.3, 0.3]]
[[], [], [], [], [0.3, 0.3]]
[[], [], [], [], [0.3, 0.3]]
[[], [], [], [], [0.3, 0.3]]
[[], [], [], [], [0.3]]
[[], [], [], [], [0.3]]
[[], [], [], [], [0.3]]
[[], [], [], [], [0.3]]
[[], [], [], [], [0.3]]
[[], [], [], [], []]
[[], [], [], [], []]
[[], [], [], [], []]
[[], [], [], [], []]
[[], [], [], [], []]
[[], [], [], [], []]
Final:
0.5 0.4 0.4 0.4 0.3
0.5 0.3
0.3
0.3
I tried creating a copy by using
self.network.copy()
but it didnt seem to have an effect
User Cycles is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.