Skip to content

Commit 980cef7

Browse files
committed
updating game logic
1 parent a30886d commit 980cef7

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Project 3 - Hungman Game/main.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
wordList = fruitList + animalList
1414
word = random.choice(wordList)
1515
category = word_Category[word]
16-
16+
print(word)
1717
if __name__ == '__main__':
1818
print(f'Guess the word! : Hint - Category {category}')
1919

@@ -24,6 +24,7 @@
2424
rounds = len(word) + 2
2525
flag = 0
2626
letterGuessed = ''
27+
chances = 3
2728

2829
print(f'---> Total Number of Rounds : {rounds} <---')
2930
try:
@@ -34,13 +35,25 @@
3435
print("Only Alhpabetic Character Allowed")
3536
if len(guess) != 1:
3637
print("Only Once Character Allowed at a Time")
38+
if guess not in word:
39+
chances -= 1
40+
print(f'Chances Remaining : {chances}')
41+
print("Correct Answer To Reset Chances")
42+
if chances == 0:
43+
print("You have Zero Chances")
44+
break
45+
break
3746
if guess in word:
47+
if chances < 3 :
48+
chances = 3
49+
print(f'Chances Reset Remaining Chances: {chances}')
3850
w = word.count(guess)
3951
for _ in range(w):
4052
letterGuessed += guess
4153
for char in word:
4254
if char in letterGuessed and (Counter(letterGuessed) != Counter(word)):
4355
print(char, end=" ")
56+
4457
elif(Counter(letterGuessed) == Counter(word)):
4558
flag = 1
4659
print(f'The word is : {word}')

0 commit comments

Comments
 (0)