geekcomputers / geekcomputers/Python
I am stuck with my Rock, Paper, Scissors python game
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 35.4k
- Forks
- 12.9k
- Avg merge
- 2h 37m
- Merged PRs (30d)
- 1
Description
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()
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the posted Python script from main() and observe the branches using random.randint(1,3). Check the behavior for Rock, Paper, and Scissors inputs in both capitalization forms. Done means the game responds consistently to all computer choices and supported user inputs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 20/100