Here's some example output when I run your script
From this, we can narrow your problem to a specific line (18).
Output:$ python tesit.py
In this game you will guess a number and the computer will try to guess it in as few tries as possible.
Enter a number 1-100 --- 50
(50, 66, 1, 66)
('\nThe computer guessed ', 66)
('\nThe computer guessed', 15)
Traceback (most recent call last):
File "tesit.py", line 18, in <module>
cNumber = random.randint(placeholder, 1)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/random.py", line 242, in randint
return self.randrange(a, b+1)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/random.py", line 218, in randrange
raise ValueError, "empty range for randrange() (%d,%d, %d)" % (istart, istop, width)
ValueError: empty range for randrange() (66,2, -64)
(Ideally you would have provided this, and saved me the step of creating a file and running it.)From this, we can narrow your problem to a specific line (18).
cNumber = random.randint(placeholder, 1)You're calling
randint
in a way such that you'll always always have this problem as soon as this line is run (unless placeholder
happens to be 1).Output:>>> random.randint(2, 1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/random.py", line 242, in randint
return self.randrange(a, b+1)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/random.py", line 218, in randrange
raise ValueError, "empty range for randrange() (%d,%d, %d)" % (istart, istop, width)
ValueError: empty range for randrange() (2,2, 0)
>>> random.randint(1, 1)
1
You should start your investigation there.