matrix = [["A", "B"], ["C", "D"]] print(' '.join([' '.join([str(cell) for cell in row]) for row in matrix]))