geekcomputers / geekcomputers/Python
I am stuck with my Rock, Paper, Scissors python game
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 35.4k
- 派生
- 12.9k
- 平均合并
- 2 小时 37 分钟
- 30 天内合并 PR
- 1
描述
I am new to GitHub so if I have posted this help request in the wrong place please let me know. I am trying to make rock, paper, scissors in python without googling the answer and I have come across an issue. I am playing around with it and the only option the computer is picking is Rock. It will not pick paper or scissors, no matter what the user inputs. Yesterday it was working fine and the computer would randomly pick something but now it only picks the number 1 or Rock, can anyone see why this is happening? Have I put some code in wrong which is causing this to happen? All help is grateful. This is my code, the def main(): and while True have not been added to the code area for some reason but in the python code they are indented properly and everything so I do not believe they are the problem.
import time
import random
def main():
while True:
computer = random.randint(1,3)
user = input("Rock, Paper, Scissors, SHOOT! ")
if computer == 1 and user == "Rock" or user == "rock":
print("I pick Rock!")
time.sleep(0.5)
print("Tie")
time.sleep(0.5)
print("Either play again or type Finished to stop!")
elif computer == 1 and user == "Paper" or user == "paper":
print("I pick Rock!")
time.sleep(0.5)
print("You win")
time.sleep(0.5)
print("Either play again or type Finished to stop!")
elif computer == 1 and user == "Scissors" or user == "scissors":
print("I pick Rock!")
time.sleep(0.5)
print("I win!")
time.sleep(0.5)
print("Either play again or type Finished to stop!")
elif computer == 2 and user == "Rock" or user == "rock":
print("I pick Paper!")
time.sleep(0.5)
print("I win!")
time.sleep(0.5)
print("Either play again or type Finished to stop!")
elif computer == 2 and user == "Paper" or user == "paper":
print("I pick Paper!")
time.sleep(0.5)
print("Tie!")
time.sleep(0.5)
print("Either play again or type Finished to stop!")
elif computer == 2 and user == "Scissors" or user == "scissors":
print("I pick Paper!")
time.sleep(0.5)
print("You win")
time.sleep(0.5)
print("Either play again or type Finished to stop!")
elif computer == 3 and user == "Rock" or user == "rock":
print("I pick Scissors!")
time.sleep(0.5)
print("You win!")
time.sleep(0.5)
print("Either play again or type Finished to stop!")
elif computer == 3 and user == "Paper" or user == "paper":
print("I pick Scissors!")
time.sleep(0.5)
print("I win")
time.sleep(0.5)
print("Either play again or type Finished to stop!")
elif computer == 3 and user == "Scissors" or user == "scissors":
print("I pick Scissors!")
time.sleep(0.5)
print("Tie!")
time.sleep(0.5)
print("Either play again or type Finished to stop!")
elif user == "Finished" or user == "finished":
print("Okay!")
break
else:
print("Sorry, that isn't an option I understand... yet.")
main()
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先从 main() 运行提供的 Python 脚本,并观察使用 random.randint(1,3) 的分支。检查 Rock、Paper 和 Scissors 输入在两种大小写形式下的行为。完成的标准是游戏能够对所有计算机选择和受支持的用户输入做出一致响应。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- cli
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 20/100