geekcomputers / geekcomputers/Python

I am stuck with my Rock, Paper, Scissors python game

Offen
#688 13 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Python
Sterne
35.4k
Forks
12.9k
Ø Merge
2 Std. 37 Min.
Gemergte PRs (30 T.)
1

Beschreibung

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()

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Führe zunächst das bereitgestellte Python-Skript ausgehend von main() aus und beobachte die Zweige, die random.randint(1,3) verwenden. Überprüfe das Verhalten für Eingaben von Rock, Paper und Scissors in beiden Groß-/Kleinschreibungsformen. Erledigt bedeutet, dass das Spiel auf alle Computerentscheidungen und unterstützten Benutzereingaben konsistent reagiert.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
cli
Issue-Typ
Bug
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
20/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.