So, I just started coding about 6 months ago. I know some HTML, CSS, and Javascript, but I felt like they were just not as fast and easy as python. I decided to start learning the pygame library. Today, I tried to make a chess board with the least amount of lines possible. Here is my code:
import pygamepygame.init()window = pygame.display.set_mode([640, 640])window.fill((0, 0, 0))x_axis = 0y_axis = 0rect = pygame.Rect(x_axis, y_axis, 80, 80)flag = Truefor y in range(0, 8): for x in range(0, 8): pygame.draw.rect(window, (255, 255, 255), rect) pygame.draw.rect(window, (101, 67, 33), rect, 5) rect = pygame.Rect(x_axis, y_axis, 80, 80) x_axis += 160 y_axis += 80 if flag: x_axis = 80 flag = False else: x_axis = 0 flag = Truepygame.display.update()pygame.time.wait(40000)
As you can see, it was 23 lines without the empty lines. I feel like this is a bit lengthy, especially for just a black and white board with brown outlines. Could someone please show me a better way to this (if there is)?