如何实现用户的历史记录功能
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from random import randint
from collections import deque
N = randint(0, 100)
deque_result = deque([], 5)
def guess(k):
if k == N:
print "right"
return True
if k < N:
deque_result.append(k)
print "%s is less than N" % k
else:
deque_result.append(k)
print "%s is greater than N" % k
return False
while True:
line = raw_input("please input a number:")
if line.isdigit():
k = int(line)
if guess(k):
break