import random def datarand(): originaldata = random.randint(1,10) return originaldata def guessdata(originaldata): flag = 0 while(flag==0): data = int(raw_input("please enter your num:")) if originaldata < data: print "to big" elif originaldata > data: print "to small" elif originaldata == data: print "You win!" flag = 1 if __name__=='__main__': data = datarand() print data guessdata(data)