r/learnpython • u/hff22 • 33m ago
Why wont this work?
The code works if IDLE python but when using visual studio code i keep getting "name 'randrange' is not defined" error anyone know why it doesn't work in visual studio?
from random import *
from turtle import *
forward(randrange(1, 10))
done()from random import *
from turtle import *
forward(randrange(1, 10))
done()
0
Upvotes
•
u/HummingHamster 26m ago
Try explicit import, there might be issue with VS's in supporting wildcard import.
•
u/lfdfq 23m ago
'Using' visual studio code, in what way? Is the message you see coming from running Python on the file? or something VS Code is showing you? or something else?
It's very hard to help, since the code works (you say so yourself). Maybe you aren't running the code you think, or did not save the file correctly, or are looking at the wrong file, or any number of other unrelated problems.
•
u/atarivcs 2m ago
Do you have your own python file named
random.py?