-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjuego-piedra-papel-tijera.py
72 lines (67 loc) · 1.75 KB
/
juego-piedra-papel-tijera.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#juego piedra papel o tijera
import random
options = ('piedra', 'papel', 'tijera')
computerWins = 0
userWins = 0
rounds = 1
while True:
print('* ' *10)
print('ROUND' , rounds)
print('* ' *10)
print('computer wins: ', computerWins)
print('User Wins: ', userWins)
user_option = input('piedra, papel o tijera: ')
user_option = user_option.lower()
rounds+=1
#validar si usuario ingresa una opcion no valida
if not user_option in options:
print('Opcion no valida.')
continue
#random de opciones
computerOption = random.choice(options)
print('user elije => ', user_option)
print('computer elije => ', computerOption)
if user_option == computerOption:
print('EMPATE')
elif user_option == 'piedra':
if computerOption == 'tijera':
print('Piedra gana a tijera')
print('User gana')
print()
userWins +=1;
else:
print('Papel gana a piedra')
print('Computer gana')
print()
computerWins +=1
elif user_option == 'papel':
if computerOption == 'piedra':
print('Papel gana a piedra')
print('User gana')
print()
userWins+=1
else:
print('Tijera gana a papel')
print('Computer gana')
print()
computerWins+=1
elif user_option == 'tijera':
if computerOption == 'papel':
print('tijera gana a papel')
print('User gana')
print()
userWins+=1
else:
print('Piedra gana a tijera')
print('Computer gana')
print()
computerWins+=1
#Definir ganador y romper ciclo
if computerWins == 2:
print('El Ganador es el Computer!')
print(f'Sus victorias son: {computerWins} ')
break
if userWins == 2:
print('El Ganador es el User')
print(f'Sus victorias son: {userWins} ')
break