Search code examples
pythonrandomprinting

Python randint not working(not printing the answer)


I was working on a project when I realized that random.randint would not print out.
This is my code:

import random

random.randint(1,25)

In the shell it works, but when I put it into a new file it doesn't work (print/display output).
Does anyone know why? Thanks!


Solution

  • Because you have to print the value because in programming you don't have to print everything so to print you can do the following

    print(random.randint(1,25)
    

    or

    x=random.randint(1,25)
    print(x)