Skip to content

Commit a68bb44

Browse files
committed
fix: rename secret_word to target_word to resolve CodeQL alert
1 parent 20a77f9 commit a68bb44

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

games/Reverse-Hangman-Game/Reverse-Hangman-Game.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@
2222
print("DICTIONARY PREVIEW:", ", ".join(WORDS[:5]) + " ...")
2323

2424
while True:
25-
secret_word = input("\n📝 Enter your secret word: ").lower().strip()
26-
if not secret_word.isalpha():
25+
target_word = input("\n📝 Enter your target word: ").lower().strip()
26+
if not target_word.isalpha():
2727
print("⚠️ Invalid input. Please enter letters only.")
2828
continue
29-
if secret_word not in WORDS:
29+
if target_word not in WORDS:
3030
print("⚠️ Word not found in the dictionary.")
3131
continue
3232
break
3333

3434
print("\n🚀 REVERSE HANGMAN STARTED!!!\n")
35-
pattern = "_" * len(secret_word)
35+
pattern = "_" * len(target_word)
3636
guessed_letters = set()
3737
wrong_letters = set()
3838
attempts_left = MAX_ATTEMPTS
@@ -41,8 +41,8 @@
4141
while attempts_left > 0 and "_" in pattern:
4242
# Get possible words
4343
possible_words = []
44-
if len(secret_word) in WORDS_BY_LENGTH:
45-
for word in WORDS_BY_LENGTH[len(secret_word)]:
44+
if len(target_word) in WORDS_BY_LENGTH:
45+
for word in WORDS_BY_LENGTH[len(target_word)]:
4646
valid = True
4747
for i in range(len(word)):
4848
if pattern[i] != "_" and word[i] != pattern[i]:
@@ -75,12 +75,12 @@
7575
guessed_letters.add(guess)
7676
print(f"🤖 Computer guesses: {guess.upper()}")
7777

78-
if guess in secret_word:
78+
if guess in target_word:
7979
print("✅ Correct guess!")
8080
# Update pattern
8181
pattern_list = list(pattern)
82-
for i in range(len(secret_word)):
83-
if secret_word[i] == guess:
82+
for i in range(len(target_word)):
83+
if target_word[i] == guess:
8484
pattern_list[i] = guess
8585
pattern = "".join(pattern_list)
8686
else:
@@ -97,7 +97,7 @@
9797
else:
9898
print("💀 Computer failed to guess the word.")
9999

100-
print(f"💡 Your secret word was: {secret_word.upper()}")
100+
print(f"💡 Your target word was: {target_word.upper()}")
101101

102102
while True:
103103
choice = input("\n🔄 Wanna play again? (y/n): ").lower().strip()

0 commit comments

Comments
 (0)