Last active
          May 18, 2017 14:52 
        
      - 
      
- 
        Save Everfighting/9cf8d5e5692a380915b3e0cc0eec746d to your computer and use it in GitHub Desktop. 
    实现用户的历史记录功能
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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