s2 = [line.strip() for line in str(sudoku).strip().splitlines()] s3 = [line.strip() for line in sudoku_str.strip().splitlines()] ...