'String before for loop
So I was just watching a tutorial about Tic Tac Toe since I wanted to know if you could make the grid with a for loop. And there i saw this line. I understand how a for loop works, but how can I place a " " before a for loop and how does it work? Also I am kinda unsure about the second for loop. What be nice if anyone could explain that to me.
sefboard = [" " for i in range(9)]
print(sefboard)
for row in [sefboard[i*3: (i+1)*3] for i in range(3)]:
print("| " + " | " + " |")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
