Apr-19-2020, 07:47 PM
i was creating a simple guessing game where in the guess is matched to the original string and completes the word.
Encountering 2 errors.
1. When wrong guess is made, the else condition is not called and python returns an error.
Traceback (most recent call last):
File "C:/Users/PycharmProjects/Study2.py", line 12, in <module>
if w.index(x):
ValueError: 'b' is not in list
2. The first letter is not replaced in the guessed word inspite of guessing correctly.
Encountering 2 errors.
1. When wrong guess is made, the else condition is not called and python returns an error.
Traceback (most recent call last):
File "C:/Users/PycharmProjects/Study2.py", line 12, in <module>
if w.index(x):
ValueError: 'b' is not in list
2. The first letter is not replaced in the guessed word inspite of guessing correctly.
print("=====Hangman =====\nGuess the letters to fill the blanks") w = ["o", "r", "a", "n", "g", "e"] b = ["_", "_", "_", "_", "_", "_"] wrong = 0 while b != w and wrong <=6: print(b) x = input("Enter your guess: ") if w.index(x): i = w.index(x) b[i] = x else: wrong += 1 if wrong == 6: print("Your are out of guesses")