Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to import random?
#1
Extremely stupid question below, beware. NSFW

Hello, I have been browsing the web and have come across a number guessing game in Python. I have created my own, but instead of me coming up with the endgame number, I want a random number for every instance.

When I type in "import random" in PyCharm, it is grayed out. Is this because I do not possess the module files? If so, how and where do I go about downloading them?

Thank you.
Reply
#2
random is part of standard python library, so you don't need to import anything. To avoid stupid mistake - don't name your own file random.py.
That said, it's not clear what the problem is. Do you get any error when you create new file, write just a single line import random, save the file under some name and run it?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  import random charlottelol 4 2,158 Nov-16-2020, 01:19 AM
Last Post: bowlofred

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020