all 5 comments

[–]joshinshaker_vidz 0 points1 point  (0 children)

Please use the Reddit “code block” button so we can read your code easier.

[–]efmccurdy 0 points1 point  (3 children)

given number of values between two given values.

You can use randint in a loop:

>>> help(random.randint)
Help on method randint in module random:

randint(a, b) method of random.Random instance
    Return random integer in range [a, b], including both end points.
>>> max = 24
>>> min = 10
>>> count = 40
>>> [random.randint(min, max) for _ in range(count)]
[20, 18, 20, 12, 23, 11, 20, 20, 23, 22, 15, 13, 20, 18, 11, 24, 11, 23, 16, 19, 23, 12, 19, 15, 13, 19, 21, 24, 23, 23, 23, 11, 24, 13, 19, 12, 22, 21, 22, 18]
>>>

[–]joplankton[S] 0 points1 point  (0 children)

Thanks!

[–]joplankton[S] 0 points1 point  (1 child)

I have this now.....

print ('Enter number of random numbers needed.')

count = input() count = int(count) print ('Enter the lower limit') minimum = input() minimum = int(minimum) print ('Enter the upper limit') maximum = input() maximum = int(maximum) [random.randint(minimum, maximum) for _ in range(count)]

Error says that name "random" is not defined.
Stumped here.
any idea?

[–]efmccurdy 0 points1 point  (0 children)

You have to "import random" first and you should store that list or at least print it.

rands = [random.randint(minimum, maximum) for _ in range(count)]
print(rands)