|
发表于 2018-1-21 12:08:05
|
显示全部楼层
- import random as r
- def win(x,y):
- if x==y:
- print('结果你平')
- elif x<y and x!=1 or x==3 and y==1:
- print('结果你输')
- else:
- print('结果你赢')
- def playGame():
- dict={1:'剪刀',2:'石头',3:'布'}
- while True:
- youChoice=input("$$\n开始猜拳咯:\n1:剪刀\n2:石头\n3:布\n")
- print('你的选择是%s'%(youChoice))
- if youChoice not in ['1','2','3']:
- print('玩啥呢,重来')
- continue
- ComChoice=r.randint(1,3)
- print('你出了%s,电脑出了%s'%(dict.get(int(youChoice)),dict.get(ComChoice)))
- win(int(youChoice),ComChoice)
- coin=input('还玩么:玩按y,其他键退出:\n')
- if coin !='y':
- break
- playGame()
复制代码 |
|