0

Hello. I have some bugs in my Code I need help

import random Hangman=( """ ------ | | | | | | | | | ---------- """, """ ------- | | | 0 | | | | | | ---------- """, """ ------- | | | 0 | /--+ | | | | | ---------- """, """ ------- | | | 0 | /--+--\ | | | | | ---------- """, """ ------- | | | 0 | /--+--\ | | | | | | ---------- """, """ ------- | | | 0 | /--+--\ | | | / | | | ---------- """, """ ------- | | | 0 | /--+--\ | | | / \ | | ---------- """ )#actual picture MAX_WRONG = len(Hangman) - 1 #Change HangMan Pics Words=("DRONE","COMPUTER","TELEPHONE","COFFEE","LAPTOP","REMARKABLE","VR") #list of words word=random.choice(Words)#Randomly pick word/shuffling guess= "_"* len(word)#For the Dashes of left answers wrong= 0 #Counter used= []#Used words print("Welcome to Hangman. Good luck!") while wrong<MAX_WRONG and guess!=word: print(Hangman[wrong]) print("\nYou've used the following letters:\n", used) print("\nSo far, you have guessed:\t", guess) answer=input("put in your Guess:") answer= answer.upper() while answer in used: print("Letter", answer," already used ",) answer = input("Guess again:\t") answer = answer.upper() used.append(answer) if guess in word: print("Nice Job") new = "" # create a new so_far to include guess for i in range(len(word)): if guess == word[i]: new += guess else: new += guess[i] guess= new else: print("Nope") wrong+=1 if wrong == MAX_WRONG: print(Hangman[wrong]) print("I would tell you, that you've been hanged. \n\ But you're dead, so.......RIP?") else: print("\nYou guessed it!") print("\nThe word was", word) input("\n\nPress Enter key to exit") If I have the right word it does not work

26th Jul 2023, 5:56 PM
Onosejele Oseaga-Ikuenobe
2 Answers
+ 3
Onosejele Oseaga-Ikuenobe Start by creating the code using the playground feature and sharing the link... In this way its much more simple run and debug it (for who want help you)
26th Jul 2023, 6:30 PM
KrOW
KrOW - avatar
+ 3
The provided Hangman game code has some minor issues. Let's correct them: The indentation of the Hangman tuple is inconsistent. All the elements of the tuple should be aligned at the same indentation level. In the part where you update the guess, there's a mistake in slicing the string. You should update the guess by replacing the underscores ('_') with the correctly guessed letter, not by repeating the guessed letter. Here's the corrected version of the code: corrected by ChatGPT 😁😎 https://code.sololearn.com/c2rsbFdVW090/?ref=app
26th Jul 2023, 8:55 PM
Jan Markus