matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] result = [] for i, row in enumerate(matrix): if i % 2 == 0: result.extend(row) else: result.extend(row[::-1]) print(result)
To embed this project on your website, copy the following code and paste it into your website's HTML: