[Tutor] error message
mike viceano
ph34r_th3_d4rkn3s at hotmail.com
Sun Oct 1 15:17:42 CEST 2006
hello i wrote a litle program ware you pick a number and the computer
guesses it and i recently decided to make it so it dosint reguess
numbers but now i get a error message
here is the program
def number(number):
from random import randrange
guess=randrange(number*2)
print guess
guessed.append(guess)
guesses=1
guessed=[]
while guess !=number:
guess=randrage(number*2)
if guess not in guessed:
guessed.append(guess) #here is ware the problem is
guesses=guesses+1
print"i got the number",number,"number","in",guesses,"guesses"
and here is the error
Traceback (most recent call last):
File "<pyshell#17>", line 1, in -toplevel-
guess.number(10)
File
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/guess.py",
line 5, in number
guessed.append(guess)
UnboundLocalError: local variable 'guessed' referenced before assignment
any help is great
_________________________________________________________________
Express yourself - download free Windows Live Messenger themes!
http://clk.atdmt.com/MSN/go/msnnkwme0020000001msn/direct/01/?href=http://imagine-msn.com/themes/vibe/default.aspx?locale=en-us&source=hmtagline
More information about the Tutor
mailing list