Skip to content

Commit d11a59d

Browse files
authored
Merge pull request #6823 from Nick-Martz/patch-2
Implement rock-paper-scissors game in Python
2 parents d35c3b3 + f7d69ec commit d11a59d

File tree

1 file changed

+41
-0
lines changed
  • Retos/Reto #6 - PIEDRA, PAPEL, TIJERA, LAGARTO, SPOCK [Media]/python

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import random as rm
2+
3+
def game_rock_papper_cut():
4+
while True:
5+
try:
6+
def condicional_game(a,b):
7+
if a ==1 and b == 2:
8+
print("Pc: 📄\nTu: 🪨")
9+
print("Perdiste")
10+
elif a ==2 and b ==3:
11+
print("Pc: ✂️\n Tu: 📄")
12+
print("Perdiste")
13+
elif a ==3 and b ==1:
14+
print("Pc: 🪨\n Tu: ✂️")
15+
print("Perdiste")
16+
elif a ==1 and b == 3:
17+
print("Pc: 🪨\nTu: 📄")
18+
print("Ganaste")
19+
elif a ==2 and b ==1:
20+
print("Pc: 📄\n Tu: 🪨")
21+
print("Ganaste")
22+
elif a ==3 and b ==2:
23+
print("Pc: ✂️\n Tu: 📄")
24+
print("Ganaste")
25+
elif a == b:
26+
print("Empate")
27+
def input_game():
28+
Player = int(input("1: Piedra\n2: Papel\n3: Tijera\n<<|>> "))
29+
Pc = rm.randint(1,3)
30+
condicional_game(Player,Pc)
31+
input_game()
32+
33+
except TypeError as TyErxx:
34+
print(TyErxx)
35+
print("😡Solamente Numeros😡")
36+
input_game()
37+
except NameError as NamErxx:
38+
print(NamErxx)
39+
except ValueError as ValErxx:
40+
print(ValErxx)
41+
game_rock_papper_cut()

0 commit comments

Comments
 (0)