Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Random module not working. ValueError: empty range for randrange() (1,1, 0)

In Python 2.7.1, I import the random module. when I call randint() however, I get the error:

ValueError: empty range for randrange() (1,1, 0) 

This error is caused by an error in the random.py module itself. I don't know how to fix it, not does reinstalling python help. I can't change versions.

can someone please give me code for a working module or tell me what to do?

like image 592
user551717 Avatar asked Dec 22 '10 21:12

user551717


1 Answers

You called randint like this:

 randint(1,0)

That tells randint to return a value starting as 1 and ending at 0. The range of numbers from 1 to zero is as you surely realize an empty range. Hence the error:

 empty range for randrange()
like image 55
Lennart Regebro Avatar answered Sep 21 '22 04:09

Lennart Regebro