python实现猜拳游戏

import random;
guess_list = ['石头', '剪刀', ''];
rules = [['石头', '剪刀'], ['剪刀', ''], ['', '石头']];
 
computer = random.choice(guess_list);
 
print(computer);
 
people = input("石头, 剪刀, 布:\n").strip();
 
isTrue = True;
 
while isTrue:
    if people not in guess_list:
        people = input("石头, 剪刀, 布:\n").strip();
    else:
        isTrue = False;
 
if people == computer:
    print('draw');
elif [computer, people] in rules:
    print('computer is win');
else:
    print('people is win');

 

posted @ 2018-10-16 11:56  子觉  阅读(1241)  评论(0编辑  收藏  举报