diff --git a/diy1.py b/diy1.py index 868c0ff..fd234dd 100644 --- a/diy1.py +++ b/diy1.py @@ -1,19 +1,20 @@ import random -player=input("玩家出拳:") -print("玩家出拳:"+player) -h=["剪刀","石头","布"] -computer=random.choice(h) -print("计算机出拳"+computer) -if player in h: - if player==computer: - print("平局") - elif player=="石头"and computer=="剪刀": - print("恭喜,你赢了") - elif player=="剪刀"and computer=="布": - print("恭喜,你赢了") - elif player=="布"and computer=="石头": - print("恭喜你,你赢了") +while True: + player=input("玩家出拳:") + print("玩家出拳:"+player) + h=["剪刀","石头","布"] + computer=random.choice(h) + print("计算机出拳"+computer) + if player in h: + if player==computer: + print("平局") + elif player=="石头"and computer=="剪刀": + print("恭喜,你赢了") + elif player=="剪刀"and computer=="布": + print("恭喜,你赢了") + elif player=="布"and computer=="石头": + print("恭喜你,你赢了") + else: + print("很遗憾,你输了") else: - print("很遗憾,你输了") -else: - print("输入错误") + print("输入错误")