M=[]
for j in range(3):
l=[]
for k in range(3):
l.append(0)
M.append(l)
print(M)
OUTPUT:[[0,0,0],[0,0,0],[0,0,0]]
But I want the output to be printed like this:
[[0, 0, 0],
[0, 0, 0],
[0, 0, 0]]
>Solution :
to print the output in the shape that you want you can do
for item in M:
if item is M[-1]:
print(f"{item}]")
elif item is M[0]:
print(f"[{item},")
else:
print(f"{item},")
instead of just printing M