Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Python - Can't Start 'Pick a Number' Challenge
I'm having trouble even getting started with this challenge due to an error message.
I practiced 'import random' in the previous videos, but now when I use that line in my code and then test 'random.randint(1, 10)' I get an error message saying that random is undefined. What's going on?
Kenneth LoveTreehouse Guest Teacher
You have a file named
random.py. When you do
from random import <blah> or
import random, Python sees that file and imports it.
is wrong.. please review the video, it should be import random.
Weird I cant access that objective anymore
Shez Azr, I have been typing 'import random'; I misstyped above.
Kenneth, is this related to the cache in Workspaces, or does the 'random.py' file need to be completely deleted? I created a new file titled 'game.py' and trying that still didn't work, giving me the same error message and showing the file it referenced as '/home/treehouse/workspace/random.py'. However, when I created a completely new Workspace, it worked. Thanks for your help!