20190919—1

 1 import random
 2 cai_quan_you_xi = ['石头','剪刀','']
 3 computer = random.choice(cai_quan_you_xi)
 4 user = input('请输入:石头、剪刀、布')
 5 while user not in cai_quan_you_xi:
 6     print('输入错误,请重新输入')
 7     user = input()
 8 print('_____战斗过程_____')
 9 print('电脑出了%s' % computer)
10 print('用户出了%s' % user)
11 if computer == user:
12     print('平局')
13 elif (computer=='石头' and user=='') or (computer=='剪刀' and user=='石头') or (computer=='' and user=='剪刀'):
14     print('用户赢了')
15 else:
16     print('用户输了')

 

posted @ 2019-09-19 15:49  小确幸Shiny  阅读(217)  评论(0编辑  收藏  举报