geekcomputers / geekcomputers/Python
I am stuck with my Rock, Paper, Scissors python game
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 35.4k
- Fork
- 12.9k
- Merge medio
- 2h 37m
- PR unite (30g)
- 1
Descrizione
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()
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia eseguendo lo script Python fornito da main() e osserva i rami che usano random.randint(1,3). Verifica il comportamento per gli input Rock, Paper e Scissors in entrambe le forme di maiuscole/minuscole. Il lavoro è completato quando il gioco risponde in modo coerente a tutte le scelte del computer e agli input utente supportati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- cli
- Tipo di issue
- Bug
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 20/100