Anyone have any ideas for cleaning up this code?(Python)
Put simply, I'm attempting to make a program that creates a grid - from scratch, so no imports or modules are included. I've finally gotten somewhere significant in this process, and it works. Question is, how can I make it better? Specifically, how can I shorten the GRAPH[g][#] part? (For reference, GRAPH is a dictionary, with integers as keys, and a list of strings as values) GRAPH = { 9:['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], 8:['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], 7:['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], 6:['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], ... 0:[...] } for g in GRAPH: for key, val in GRAPH.items(): GRAPH[g][0] = grid GRAPH[g][1] = grid GRAPH[g][2] = grid GRAPH[g][3] = grid GRAPH[g][4] = grid GRAPH[g][5] = grid GRAPH[g][6] = grid GRAPH[g][7] = grid GRAPH[g][8] = grid GRAPH[g][9] = grid print(g, *GRAPH[g], sep="")