-2
[[' ' for _ in range(9)][i*3:(i+1)*3] for i in range(3)]

I've run this code in anaconda but how this thing worked I couldn't understand.
Can anyone please explain how does this little piece of code worked?

furas
  • 119,752
  • 10
  • 94
  • 135
  • Can this answer your problem? https://www.w3schools.com/python/python_lists_comprehension.asp – Mechanic Pig May 29 '22 at 09:51
  • 1
    Note that `[' ' for _ in range(9)][i*3:(i+1)*3]` is a particularly 'convoluted', to put it mildly, way to write `[' ', ' ', ' ']`. Not an example to follow in any way... – Thierry Lathuille May 29 '22 at 09:57

0 Answers0