I am trying to create a bingo card generator, but while I was testing it a ran into a problem. When the I use the random.choice() module to generate a random number it returns the following error:
Traceback (most recent call last): File "c:\Users\thomp\randomsquarechooser.py", line 1, in <module> import random File "c:\Users\thomp\randomsquarechooser.py", line 7, in <module> cs = random.choice(squares) ^^^^^^^^^^^^^AttributeError: partially initialized module 'random' has no attribute 'choice' (most likely due to a circular import)
This is my code:
import randomfrom time import sleepsquares = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13","14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24"]for i in range(24): cs = random.choice(squares) print(cs) squares.remove(cs) sleep(0.5)
This code works fine in both the Python 3.12 IDLE and in repl.it (browser-based IDLE). What is the problem here and is there an alternative? I use Vscode in most of my projects, so I would rather find a solution than use a different editor
I am a rookie python coder, so please do not mind if I'm being stupid here.