def prettyPrintMatrix(matrix): s = [[str(e) if not e is None else " - " for e in row] for row in matrix] lens = [max(map(len, col)) for col in zip(*s)] fmt = '\t'.join('{{:{}}}'.format(x) for x in lens) table = [fmt.format(*row) for row in s] print('\n'.join(table))