From d607fd39d216ae4ee0a1765464527938f57da1cc Mon Sep 17 00:00:00 2001 From: pythonboi Date: Tue, 24 Aug 2021 01:05:37 -0400 Subject: [PATCH 1/2] update the code --- Hangman.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/Hangman.py b/Hangman.py index c44356f..ab34c6b 100644 --- a/Hangman.py +++ b/Hangman.py @@ -11,7 +11,8 @@ # Creating an empty list display = [] -print(chosen_word) +# Printing out the guess word +print(f"Psst, the guess word is:", chosen_word) # Print out the Guess Letter print("Guess a Letter: ", end="") @@ -27,23 +28,17 @@ for char in chosen_word: # display += "_" display.append("_") -print(display) +# print(display) # for num in range(len(chosen_word)): # # for check in chosen_word: # count = count + 1 # print(count) + +# Making a For loop to count the number of guess and make an index of that number with the missing blanks + for check in range(len(chosen_word)): if guess in chosen_word[check]: display[check] = guess - - # for check in chosen_word: - # # print(num) - # if guess in check: - # print(num) - # print("Yes") - # else: - # print("No") - print(display) From 87600cc03ca9c1133f95b75cb58c7b73190bfc6d Mon Sep 17 00:00:00 2001 From: pythonboi Date: Tue, 24 Aug 2021 01:42:26 -0400 Subject: [PATCH 2/2] modify the code update the for loop for display --- Hangman.py | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/Hangman.py b/Hangman.py index ab34c6b..646caf8 100644 --- a/Hangman.py +++ b/Hangman.py @@ -14,31 +14,27 @@ # Printing out the guess word print(f"Psst, the guess word is:", chosen_word) -# Print out the Guess Letter -print("Guess a Letter: ", end="") - -# Take input from the user from the Keyboard -guess = input() - -# change the input character from Capital letter to Lowercase letter of the use input -guess = guess.lower() - -count = 0 - +# For loop for creating the dash sign for char in chosen_word: # display += "_" display.append("_") # print(display) -# for num in range(len(chosen_word)): -# # for check in chosen_word: -# count = count + 1 -# print(count) +while True: + + # Print out the Guess Letter + print("Guess a Letter: ", end="") + + # Take input from the user from the Keyboard + guess = input() + + # change the input character from Capital letter to Lowercase letter of the use input + guess = guess.lower() -# Making a For loop to count the number of guess and make an index of that number with the missing blanks + # Making a For loop to count the number of guess and make an index of that number with the missing blanks -for check in range(len(chosen_word)): - if guess in chosen_word[check]: - display[check] = guess + for check in range(len(chosen_word)): + if guess in chosen_word[check]: + display[check] = guess -print(display) + print(display)