-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjogo.py
More file actions
30 lines (21 loc) · 849 Bytes
/
jogo.py
File metadata and controls
30 lines (21 loc) · 849 Bytes
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
import random
banco_palavras = ["remo", "paysandu", "belem", "introdução", "pomine"]
palavra = random.choice(banco_palavras)
seletorPalavra = ['_'] * len(palavra)
tentativas = 5
while tentativas > 0:
print('\nPalavra: ' + ' '.join(seletorPalavra))
chute = input('Digite uma letra: ').lower()
if chute in palavra:
for i in range(len(palavra)):
if palavra[i] == chute:
seletorPalavra[i] = chute
print('Parabéns! Você acertou \o/')
else:
tentativas -= 1
print('Você errou ! tentativas restantes: ' + str(tentativas))
if '_' not in seletorPalavra:
print('\nParabéns! A palavra é: ' + palavra)
break
if tentativas == 0 and '_' in seletorPalavra:
print('\nSuas tentativas acabaram! A palavra era: ' + palavra)