+ 1

Choosing a random number from a range specified by a variable

Hello, I am trying to make a system that generates a certain amount of random numbers out of a certain range. The amount and the range are specified by a user something like this but it isn't working. a = float(input('Amount of numbers = ')) x = float(input('Minimum = ')) y = float(input('Maximum = ')) import random for g in range(a): print(random.randint(x, y)) Can someone please take a look and let me know what my error is? Thank you so much

18th Jan 2018, 7:41 PM
Nitay Eshed
Nitay Eshed - avatar
2 ответов
+ 1
I think the paramater of the range should be an integer and not a float. If you change the type of the variable "a" to int it should work.
18th Jan 2018, 7:55 PM
Jente
+ 1
thank you. it works now
19th Jan 2018, 11:47 AM
Nitay Eshed
Nitay Eshed - avatar