-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWORD_GUESS.PY
30 lines (30 loc) · 873 Bytes
/
WORD_GUESS.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
import random
print("Welcome to the Word Guess Game!")
print("You have to guess the word in 5 attempts.")
words = ['rainbow', 'computer', 'science', 'programming',
'python', 'mathematics', 'player', 'condition',
'reverse', 'water', 'board', 'geeks']
word=random.choice(words)
print("Guess the characters")
guesses = ''
turns = 5
while turns > 0:
failed = 0
for char in word:
if char in guesses:
print(char)
else:
print("_")
failed += 1
if failed == 0:
print("You Win")
print("The word is: ", word)
break
guess = input("guess a character:")
guesses += guess
if guess not in word:
turns -= 1
print("Wrong")
print("You have", + turns, 'more guesses')
if turns == 0:
print("You Loose")