Guest User

Untitled

a guest
Nov 9th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.17 KB | None | 0 0
  1. import random
  2. mode = input("Do you want to play against a friend or a computer? ")
  3. if mode == ("friend"):
  4. print("you have friends??")
  5.  
  6. lives = int(input("how many miserable lives(guesses) do you want your friend to have? "))
  7.  
  8. alpha = "qwertyuiopasdfghjklzxcvbnm1234567890"
  9. alphalist = list(alpha)
  10. word = input("Enter a word for your friend to guess: ")
  11. word = word.lower()
  12. wordArray = list(word)
  13. display = ['-' for x in wordArray]
  14. wrongArray = []
  15. win = True
  16.  
  17.  
  18.  
  19.  
  20.  
  21. print("""
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63. """)
  64. while True:
  65. print("".join(display))
  66. guess = input("Enter a guess: ")
  67.  
  68.  
  69. if guess in alphalist:
  70.  
  71. if guess != (""):
  72.  
  73. if guess in wordArray:
  74. if guess not in display:
  75. print("You found a letter!")
  76. print("You have " + str(lives) + " lives left")
  77. for i in range(len(wordArray)):
  78. if guess is wordArray[i]:
  79. display[i] = guess
  80. else:
  81. print("You already guessed that!")
  82. else:
  83. if guess not in wrongArray:
  84. print("Incorrect guess, try again!")
  85. wrongArray.append(guess)
  86. lives = lives - 1
  87. print("You have " + str(lives) + " lives left")
  88. else:
  89. print("You already guessed that wrongly. people never learn from their mistakes :(")
  90. if lives <= 0:
  91. print("Game over - you ran out of lives. The word was '" + (word) + "'")
  92. win = False
  93. break
  94. if '-' not in display:
  95. break
  96. else:
  97. print("please enter a character")
  98. else:
  99. print("pleaase enter a valid character")
  100.  
  101.  
  102. if win is True:
  103. print("Good job! you guessed '" + str("".join(display)) + " 'correctly")
  104.  
  105.  
  106. elif mode == ("computer"):
  107. print("as expected of a loner such as yourself")
  108. alpha = "qwertyuiopasdfghjklzxcvbnm"
  109. alphalist = list(alpha)
  110. dif = input("Easy(1), Medium(2), or Hard(3)? ")
  111.  
  112. with open('easylist.txt', 'r') as f:
  113. a = f.read()
  114. dicE = [a[i:i+3] for i in range(0, len(a), 3)]
  115.  
  116. with open('medlist.txt', 'r') as f:
  117. a = f.read()
  118. dicM = [a[i:i+5] for i in range(0, len(a), 5)]
  119.  
  120. with open('hardlist.txt', 'r') as f:
  121. a = f.read()
  122. dicH = [a[i:i+7] for i in range(0, len(a), 7)]
  123.  
  124. if dif == ("1"):
  125. word = random.choice(dicE)
  126. wordArray = list(word)
  127. display = ['-' for x in wordArray]
  128. lives = 10
  129. wrongArray = []
  130. win = True
  131. print("Easy Mode! Three letters: ---")
  132. while True:
  133. print("".join(display))
  134. guess = input("Enter a guess: ")
  135.  
  136.  
  137. if guess in alphalist:
  138. if guess != (""):
  139.  
  140. if guess in wordArray:
  141. if guess not in display:
  142. print("You found a letter!")
  143. print("You have " + str(lives) + " lives left")
  144. for i in range(len(wordArray)):
  145. if guess is wordArray[i]:
  146. display[i] = guess
  147. else:
  148. print("You already guessed that!")
  149. else:
  150. if guess not in wrongArray:
  151. print("Incorrect guess, try again!")
  152. wrongArray.append(guess)
  153. lives = lives - 1
  154. print("You have " + str(lives) + " lives left")
  155. else:
  156. print("You already guessed that wrongly. people never learn from their mistakes :(")
  157. if lives <= 0:
  158. print("Game over - you ran out of lives. The word was '" + (word) + "'")
  159. win = False
  160. break
  161. if '-' not in display:
  162. break
  163. else:
  164. print("please enter a character")
  165. else:
  166. print("pleaase enter a valid character")
  167.  
  168.  
  169. if win is True:
  170. print("Good job! you guessed '" + str("".join(display)) + " 'correctly")
  171.  
  172.  
  173. elif dif == ("2"):
  174. word = random.choice(dicM)
  175. wordArray = list(word)
  176. display = ['-' for x in wordArray]
  177. lives = 10
  178. wrongArray = []
  179. win = True
  180. print("Medium Mode! Five letters: -----")
  181. while True:
  182. print("".join(display))
  183. guess = input("Enter a guess: ")
  184.  
  185.  
  186. if guess in alphalist:
  187. if guess != (""):
  188.  
  189. if guess in wordArray:
  190. if guess not in display:
  191. print("You found a letter!")
  192. print("You have " + str(lives) + " lives left")
  193. for i in range(len(wordArray)):
  194. if guess is wordArray[i]:
  195. display[i] = guess
  196. else:
  197. print("You already guessed that!")
  198. else:
  199. if guess not in wrongArray:
  200. print("Incorrect guess, try again!")
  201. wrongArray.append(guess)
  202. lives = lives - 1
  203. print("You have " + str(lives) + " lives left")
  204. else:
  205. print("You already guessed that wrongly. people never learn from their mistakes :(")
  206. if lives <= 0:
  207. print("Game over - you ran out of lives. The word was '" + (word) + "'")
  208. win = False
  209. break
  210. if '-' not in display:
  211. break
  212. else:
  213. print("please enter a character")
  214. else:
  215. print("pleaase enter a valid character")
  216.  
  217.  
  218. if win is True:
  219. print("Good job! you guessed '" + str("".join(display)) + " 'correctly")
  220.  
  221.  
  222.  
  223. elif dif == ("3"):
  224. word = random.choice(dicH)
  225. wordArray = list(word)
  226. display = ['-' for x in wordArray]
  227. lives = 10
  228. wrongArray = []
  229. win = True
  230. print("Hard Mode! Seven letters: -------")
  231. while True:
  232. print("".join(display))
  233. guess = input("Enter a guess: ")
  234.  
  235.  
  236. if guess in alphalist:
  237. if guess != (""):
  238.  
  239. if guess in wordArray:
  240. if guess not in display:
  241. print("You found a letter!")
  242. print("You have " + str(lives) + " lives left")
  243. for i in range(len(wordArray)):
  244. if guess is wordArray[i]:
  245. display[i] = guess
  246. else:
  247. print("You already guessed that!")
  248. else:
  249. if guess not in wrongArray:
  250. print("Incorrect guess, try again!")
  251. wrongArray.append(guess)
  252. lives = lives - 1
  253. print("You have " + str(lives) + " lives left")
  254. else:
  255. print("You already guessed that wrongly. people never learn from their mistakes :(")
  256. if lives <= 0:
  257. print("Game over - you ran out of lives. The word was '" + (word) + "'")
  258. win = False
  259. break
  260. if '-' not in display:
  261. break
  262. else:
  263. print("please enter a character")
  264. else:
  265. print("pleaase enter a valid character")
  266.  
  267.  
  268. if win is True:
  269. print("Good job! you guessed '" + str("".join(display)) + " 'correctly")
Add Comment
Please, Sign In to add comment