# -*- coding: utf-8 -*- """ Created on Tue Dec 8 02:18:02 2020 @author: alper """ # Hangman word game import numpy as np Word_List=["oguzhandic","twitch","moderator", "kasa","random","oguzhanabikalp", "alptekinsss"] HangedMan="ICO>-:<--<" False_try= len(HangedMan) SelWord=Word_List[np.random.randint(0, len(Word_List)-1)] Tried_letters=[] GuessWord=[] for i in range(len(SelWord)): GuessWord.append("_ ") NumOfFail= 0 while "_ " in GuessWord: ch= input("Enter a character for guess the word: ") if ch not in SelWord and ch != " ": NumOfFail= NumOfFail + 1 Tried_letters.append(ch) print("You tried this letters before: ", Tried_letters) print("Your current status is: ") for i in range(NumOfFail): print(HangedMan[i], end="") if NumOfFail == False_try: print("\nYou failed.\nThe word is ", SelWord) break else: for i in range(len(SelWord)): if SelWord[i]==ch.lower() or SelWord[i]==ch.upper(): GuessWord[i]=ch.upper() print("Congrulations! Your guess is correct") print("Let Guess This: ", GuessWord) print("You tried this letters before: ", Tried_letters) if "_ " not in GuessWord: print("Congrulations! You WON!") break