diff --git a/app.py b/app.py index 8c27ec75..8be6311b 100644 --- a/app.py +++ b/app.py @@ -4,8 +4,47 @@ #----------------------------------------------------------------------------------------- from flask import Flask +import random app = Flask(__name__) @app.route("/") def hello(): return app.send_static_file("index.html") +# write 'hello world' to the console +print("hello world") + +def play_game(): + options = ["rock", "paper", "scissors"] + player_score = 0 + opponent_score = 0 + + while True: + player_choice = input("Elige una opción (rock, paper, scissors): ").lower() + + if player_choice not in options: + print("Opción no válida. Por favor, elige entre rock, paper o scissors.") + continue + + opponent_choice = random.choice(options) + print("El oponente eligió:", opponent_choice) + + if player_choice == opponent_choice: + print("Empate!") + elif (player_choice == "rock" and opponent_choice == "scissors") or \ + (player_choice == "scissors" and opponent_choice == "paper") or \ + (player_choice == "paper" and opponent_choice == "rock"): + print("¡Ganaste!") + player_score += 1 + else: + print("Perdiste.") + opponent_score += 1 + + play_again = input("¿Quieres jugar de nuevo? (s/n): ").lower() + if play_again != "s": + break + + print("Puntuación final:") + print("Jugador:", player_score) + print("Oponente:", opponent_score) + +play_game()