├── __pycache__ └── words.cpython-39.pyc ├── hangman.py └── words.py /__pycache__/words.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Supraav/hangman/master/__pycache__/words.cpython-39.pyc -------------------------------------------------------------------------------- /hangman.py: -------------------------------------------------------------------------------- 1 | import random 2 | from words import words 3 | import time 4 | def play(): 5 | # name= input("hello what is your name? \n") 6 | # print('hello '+ name + ' welcome to HANGMAN. LEts Play!!!!!! \n') 7 | # print("GAME STARTS NOW \n GOOD LUCK!!!!\n") 8 | 9 | HANGMAN = [''' 10 |       +---+ 11 |           | 12 |           | 13 |           | 14 |          ===''', ''' 15 |       +---+ 16 |       O   | 17 |          | 18 |          | 19 |         ===''', ''' 20 |      +---+ 21 |      O   | 22 |      |   | 23 |          | 24 |         ===''', ''' 25 |      +---+ 26 |      O   | 27 |     /|   | 28 |          | 29 |         ===''', ''' 30 |      +---+ 31 |      O   | 32 |     /|\  | 33 |          | 34 |         ===''', ''' 35 |      +---+ 36 |      O   | 37 |     /|\  | 38 |     /    | 39 |         ===''', ''' 40 |      +---+ 41 |      O   | 42 |     /|\  | 43 |     / \  | 44 |         ==='''] 45 | 46 | # GET RANDOM WORDS FROM words.py AND PRINT IT IN UPPER CASE 47 | # def get_word(words): 48 | # word=random.choice(words) 49 | # return word.upper() 50 | 51 | a=random.choice(words) 52 | word=a.upper() 53 | # print(word) 54 | 55 | #DASH FOR THE RANDOM WORD 56 | dashed_words= '_ ' * len(word) 57 | print(dashed_words) 58 | print(word) 59 | 60 | chances=len(HANGMAN)-1 61 | 62 | #wrong guess count 63 | wrong_guess=0 64 | 65 | #guessed word 66 | guessed_words=[] 67 | 68 | #logic 69 | while (dashed_words.replace(" ", "")!=word and wrong_guess