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 trial

Python Python Basics (Retired) Pick a Number! Any Number! The Solution

Pooja Kuntal
Pooja Kuntal
705 Points

import 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
STAFF
Kenneth Love
Treehouse Guest Teacher

Since 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
Pooja Kuntal
705 Points

hey thanks Kenneth.

Chris Robinson
Chris Robinson
4,491 Points

Hah! This was my mistake too.