python2 [Python] List cannot be an element in a set; use Tuple You can't add a list to a set because lists are mutable, meaning that you can change the contents of the list after adding it to the set. Ref https://stackoverflow.com/questions/1306631/add-list-to-set 2022. 4. 23. Rotate Matrix def rotate_matrix(grid): return list(map(list, zip(*reversed(grid)))) def print_matrix(grid): for row in grid: print(row) print('----') grid = [['1', '2'], ['.', '0']] # check original matrix print_matrix(grid) # reverse the outer list print_matrix(list(reversed(grid))) # zip the reversed list print_matrix(rotate_matrix(grid)) Ref https://stackoverflow.com/questions/53242961/rotating-a-list-of-l.. 2022. 4. 16. 이전 1 다음