Skip to content

Commit 6ba1f82

Browse files
committed
Game Updated
1 parent c84e985 commit 6ba1f82

File tree

1 file changed

+35
-0
lines changed
  • Project 2 - Word Guessing Game

1 file changed

+35
-0
lines changed
+35
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,37 @@
1+
import random
12

3+
Name = input("Please Enter your name : ")
4+
print(f'Hey, Welcome Mr.{Name}')
5+
6+
words = ['rainbow', 'computer', 'science', 'programming', 'python', 'mathematics', 'player', 'condition', 'reverse', 'water',]
7+
8+
word = random.choice(words)
9+
10+
guesses = ''
11+
rounds = len(word) + 1
12+
while(rounds):
13+
failed = 0
14+
print(f'----------> Total Rounds : {rounds} <----------')
15+
16+
for char in word:
17+
if char in guesses:
18+
print(char, end=" ")
19+
else:
20+
print("_")
21+
failed += 1
22+
23+
if(failed == 0):
24+
print(f'===> You Won the Game <===')
25+
print(f'The word is : {word}')
26+
break
27+
28+
guess = input("Guess a letter : ")
29+
guesses += guess
30+
31+
if guess not in word:
32+
print("Wrong")
33+
rounds -= 1
34+
print(f'************** Remaining Rounds :{rounds} **************')
235

36+
if(rounds == 0):
37+
print("Sorry You Loose")

0 commit comments

Comments
 (0)