A fun project i did in my free time. Please do review it!!
Nice! I will wait to see that
word_to_guess=“”
found_letters=
incorrect_guess_count=0
hints=
def hangman():
def accept():
global word_to_guess
global hints
word_to_guess = input(“Enter word for other team to guess!”).upper().strip()
print(f"The word you entered is {word_to_guess.upper()}, right?")
validate_input = input(“Enter yes/no”).lower().strip()
if validate_input != ‘yes’:
accept()
print(“Enter 2 hints for other team”)
print(“Hints will be displayed only if guess is incorrect”)
hints = [input(“Enter 1st hint”), input(“Enter second hint”)]
def setter():
global found_letters
print("You have to guess a word")
for i in range(len(word_to_guess)):
found_letters.append("_ ")
def guess():
global incorrect_guess_count
if "_ " not in found_letters:
print("U have guessed it correctly! congratulations!")
print(f"The word was {word_to_guess}")
return None
print("Guesses so far: ")
for i in range(len(found_letters)):
print(found_letters[i], end=" ")
print()
next_guess = input("Guess next letter: ").upper()
if not next_guess.isspace():
next_guess = next_guess.strip()[0]
if next_guess in word_to_guess:
if word_to_guess.count(next_guess) > 1:
for j in range(len(word_to_guess)):
if word_to_guess[j] == next_guess:
found_letters[j] = next_guess
else:
found_letters[word_to_guess.index(next_guess)] = next_guess
else:
print(f"Incorrect Guess! You have {5 - incorrect_guess_count} incorrect guesses left!")
print(f'''The hints are:
{hints[0]}
{hints[1]}''')
incorrect_guess_count += 1
if incorrect_guess_count > 5:
print("You have failed to guess")
print(f"The word was {word_to_guess}")
return None
guess()
accept()
setter()
guess()
hangman()
while True:
continue_game = input(“Continue game to next round? (yes/no)”).lower().strip()
if continue_game != ‘yes’:
break
hangman()