Importing random doesnt work

Question:
so ive been making a game with a freind and suddenly my replit said this in console when using a random function:
type error: ‘module’ object is not callable
Repl link:
couldnt tell what to put here unless if it wants me to link the game

code snippet
import random

if random(1,2) == 1:
  print("test")
else:
  print("test")

Hey @victorbaucum welcome to the forums!

There is an error in your code, here is the updated code →

import random

if random.randint(1,2) == 1:
  print("test")
else:
  print("test")

You were trying to get a random integer to do that you must use randint. Hope this helps!

3 Likes

thanks tbh i expected it to be a bit more toxic here lol but i was wrong so yay

@victorbaucum the community here is very nice and welcoming. We are trying to help everyone we can, so I’m glad you didn’t find it toxic.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.