From a0f5dd4265855f994079bd342d7e729e2dc8b831 Mon Sep 17 00:00:00 2001 From: BellCodeEditor <bellcode_dev@bell.ai> Date: Sat, 23 Oct 2021 14:50:51 +0800 Subject: [PATCH] save project --- diy1.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/diy1.py b/diy1.py index 5d1b124..185bb99 100644 --- a/diy1.py +++ b/diy1.py @@ -4,13 +4,16 @@ import random list=["剪刀","石头","布"] computer=random.choice(list) print("计算机出拳"+computer) -if player==computer: - print("平局") -elif player=="布" and computer=="石头": - print("恭喜,你赢了") -elif player=="石头" and computer=="剪刀": - print("恭喜,你赢了") -elif player=="剪刀" and computer=="布": - print("恭喜,你赢了") +if player in list: + if player==computer: + print("平局") + elif player=="布" and computer=="石头": + print("恭喜,你赢了") + elif player=="石头" and computer=="剪刀": + print("恭喜,你赢了") + elif player=="剪刀" and computer=="布": + print("恭喜,你赢了") + else: + print("你输了") else: - print("你输了") \ No newline at end of file + print("输入错误") \ No newline at end of file -- libgit2 0.25.0