Answer the question
In order to leave comments, you need to log in
How to make the random operator accept a range of numbers from the user?
For example, we take the variable n and assign it a random value from 1 to 5:
import random
n = random.randint (1, 5)
Answer the question
In order to leave comments, you need to log in
Have you tried learning Python?
import random
a = int(input())
b = int(input())
n = random.randint (a, b)
Or like this:
import random
n = random.randint (int(input()),int(input()))
In this case, two numbers will be entered from a new line .. import random
rng = input().split()
rng = [int(i) for i in rng]
n = random.randint (rng[0], rng[1])
In such a number will be written in one line separated by a space
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question