23 lines
614 B
Python
23 lines
614 B
Python
import random
|
|
|
|
def juego():
|
|
user = ''
|
|
while user not in ['r', 'p', 't']:
|
|
print("Elige es tu jugada")
|
|
user = input("'r' es Roca, 'p' es Papel, 't' es Tijeras\n\t-> ")
|
|
pc = random.choice(['r', 'p', 't'])
|
|
if user == pc:
|
|
return 'Empate 👻️ '
|
|
# r > t, t > p, p > r
|
|
if victoria(user, pc):
|
|
return 'Ganaste ✌️ '
|
|
return 'Perdiste 🤥️ '
|
|
|
|
def victoria(p, op):
|
|
""" Devuelve verdadero si el jugador gana """
|
|
if (p == 'r' and op == 't') or (p == 't' and op == 'p') or (p == 'p' and op == 'r'):
|
|
return True
|
|
return False
|
|
|
|
print(juego())
|