You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def ganador(juego):
# Contadores para las victorias de cada jugador
player1 = 0
player2 = 0
# Iteramos sobre cada ronda del juego
for i in juego:
# Comprobamos todas las combinaciones posibles
# Si el jugador 1 gana, aumentamos su contador
if i[0] == "P" and i[1] == "R":
player1 = player1 + 1
if i[0] == "R" and i[1] == "S":
player1 = player1 + 1
if i[0] == "S" and i[1] == "P":
player1 = player1 + 1
# Si el jugador 2 gana, aumentamos su contador
if i[1] == "P" and i[0] == "R":
player2 = player2 + 1
if i[1] == "R" and i[0] == "S":
player2 = player2 + 1
if i[1] == "S" and i[0] == "P":
player2 = player2 + 1
# Determinamos el ganador comparando los contadores
if player1 > player2:
return print("Jugador 1 ganó")
if player2 > player2: # Nota: Hay un error aquí, debería ser player2 > player1
return print("Jugador 2 ganó")
if player1 == player2:
return print("Empate")
Llamamos a la función con nuestro juego de ejemplo
ganador(juego)
`
The text was updated successfully, but these errors were encountered:
`juego = [("R", "S"), ("S", "R"), ("P", "S")]
def ganador(juego):
# Contadores para las victorias de cada jugador
player1 = 0
player2 = 0
Llamamos a la función con nuestro juego de ejemplo
ganador(juego)
`
The text was updated successfully, but these errors were encountered: