daily pastebin goal
64%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import random
  2. listofwords = []
  3. with open("words.txt") as x:
  4.     words = list(x)
  5. rword = words[random.randint(1, len(words))]
  6. lenrword = len(rword)
  7. print("The Length of the word :", lenrword-1)
  8. correct_word = []
  9. i = 1
  10. while i <= lenrword-1:
  11.     correct_word.append("_ ")
  12.     i += 1
  13. entered = []
  14. while "_ " in correct_word:
  15.     print(' '.join(correct_word))
  16.     guess = input("Enter you guess : ")
  17.     if guess.upper() in entered:
  18.         print("You have already entered that")
  19.         entered.append(guess.upper())
  20.     else:
  21.         entered.append(guess.upper())
  22.         count = 0
  23.         for w in rword:
  24.             if guess.upper() == w:
  25.                 correct_word[count] = w
  26.                 count += 1
  27.             else:
  28.                 count += 1
  29. print("Bingo!! The word is : " + ''.join(correct_word))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top