geekcomputers / geekcomputers/Python
I am stuck with my Rock, Paper, Scissors python game
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 35.4k
- Forks
- 12.9k
- Merge medio
- 2 h 37 min
- PR fusionados (30 d)
- 1
Descripción
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()
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Empieza ejecutando el script de Python proporcionado desde main() y observa las ramas que usan random.randint(1,3). Comprueba el comportamiento para entradas de Rock, Paper y Scissors en ambas formas de capitalización. Se considera completado cuando el juego responde de forma coherente a todas las elecciones del ordenador y a las entradas de usuario compatibles.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- cli
- Tipo de issue
- Error
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 20/100