Skip to content
Advertisement

Hangman in Python: Type error raised when trying to display guessed letters along blank space

the following codes are for the Hangman game. It gets a type error for the assignment display = list("_" * len(chosen_word)), saying that it is a Nonetype. Is this because chosen_word is not assigned (which is another error in itself)?. How can it be corrected? Any other suggestion to improve the code is also welcomed.

JavaScript

Error 1 (resolved):

JavaScript

Error 2 : after a few guesses, index gets of range

JavaScript

Advertisement

Answer

Following code worked perfectly,

JavaScript

I have just added above code and some minor changes in if-else conditions and some print statements. Remove extra print statements if you want!

Full code-

JavaScript

let me know if there is any difficulty!!

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement