Skip to content

Instantly share code, notes, and snippets.

@Everfighting
Last active May 18, 2017 14:52
Show Gist options
  • Save Everfighting/9cf8d5e5692a380915b3e0cc0eec746d to your computer and use it in GitHub Desktop.
Save Everfighting/9cf8d5e5692a380915b3e0cc0eec746d to your computer and use it in GitHub Desktop.
实现用户的历史记录功能
from random import randint
from collections import deque
N = randint(0,100)
history = deque([],5)
def guess(k):
if k == N:
print('right')
return True
if k < N:
print("%s is less-than N" % k)
else:
print("%s is greater-than N" % k)
return False
while True:
line = input("Please input a number: ")
if line.isdigit():
k = int(line)
history.append(k)
if guess(k):
break
elif: line == 'history' or line == 'h?':
print(list(history))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment