Skip to content

Commit 804d2b4

Browse files
Merge pull request #2721 from avinashkranjan/deepsource-transform-76bf26d7
format code with autopep8
2 parents b73042b + b85474f commit 804d2b4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Word Chain Game/word_chain_game.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
# Existing code (is_valid_word, is_valid_move, word_list)
66

77
# Additional features
8+
9+
810
def get_word_length_difficulty(difficulty):
911
if difficulty == "Easy":
1012
return 3
@@ -15,9 +17,11 @@ def get_word_length_difficulty(difficulty):
1517
else:
1618
raise ValueError("Invalid difficulty level.")
1719

20+
1821
def get_random_letter():
1922
return random.choice(string.ascii_lowercase)
2023

24+
2125
def get_hint(prev_word):
2226
# Simple hint: Suggest a valid word with one letter change from prev_word
2327
for _ in range(10): # Try 10 times to find a hint
@@ -26,6 +30,7 @@ def get_hint(prev_word):
2630
return new_word
2731
return None # Return None if a hint can't be found
2832

33+
2934
def word_chain_game():
3035
# Existing code
3136

@@ -104,14 +109,17 @@ def check_time_elapsed(start_time, max_time):
104109

105110
# Check if player's word is too short for the difficulty level
106111
if len(new_word) < word_length_required:
107-
print(f"Word should be at least {word_length_required} letters long for {difficulty} difficulty.")
112+
print(
113+
f"Word should be at least {word_length_required} letters long for {difficulty} difficulty.")
108114
print("You lose this round.")
109115
break
110116

111117
# Check if the game should end
112118
if player_turn > 1 and not is_valid_move(chain[-2], chain[-1]):
113-
print(f"Game over! {player_name} cannot find a valid word. {player_name} wins!")
119+
print(
120+
f"Game over! {player_name} cannot find a valid word. {player_name} wins!")
114121
break
115122

123+
116124
if __name__ == "__main__":
117125
word_chain_game()

0 commit comments

Comments
 (0)