Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialPooja Kuntal
705 Pointsimport random
I am unable to import random library properly. Getting following error :
Traceback (most recent call last):
File "random.py", line 2, in <module>
import random
File "/home/treehouse/workspace/random.py", line 4, in <module>
random.randint(1, 4)
AttributeError: 'module' object has no attribute 'randint'
3 Answers
Kenneth Love
Treehouse Guest TeacherSince you named your file random.py
, Python is importing it when you do import random
. Rename your file and you should be fine.
Pooja Kuntal
705 Pointshey thanks Kenneth.
Chris Robinson
4,491 PointsHah! This was my mistake too.