Im trying to run my code o vscode anda I have the following error while importing some constants from another file: "ImportError: attempted relative import with no known parent package".
import pygame
from .constants import BLACK, ROWS, RED, SQUARE_SIZE
class Board():
def __init__(self):
self.board = []
self.selected_piece = None
self.red_left = self.white_left = 12
self.red_kings = self.white_kings = 0
def draw_squares(self, win):
#Win es window
win.fill(BLACK)
for row in range (ROWS):
for col in range(row % 2, ROWS, 2):
pygame.draw.rect(win, RED (row*SQUARE_SIZE, col*SQUARE_SIZE, SQUARE_SIZE, SQUARE_SIZE))
The file constants just contains some constants with height and width of the window
constants.py
import pygame
WIDTH, HEIGHT = 800, 800
ROWS, COLS = 8,80
SQUARE_SIZE = WIDTH//COLS
RED = (255,0,0)
WHITE = (255,255,255)
BLACK = (0,0,0)
BLUE = (0,0,255)