Hangman


SUBMITTED BY: Guest

DATE: Sept. 12, 2014, 8:14 p.m.

FORMAT: Python

SIZE: 2.4 kB

HITS: 854

  1. # Hangman v1.0 by CykoRat
  2. # 13/Sep/2014
  3. import random
  4. hangman = (
  5. """
  6. -------
  7. |
  8. O
  9. |
  10. """,
  11. """
  12. -------
  13. |
  14. O
  15. /|\
  16. """,
  17. """
  18. -------
  19. |
  20. O
  21. /|\
  22. |
  23. """,
  24. """
  25. -------
  26. |
  27. O
  28. /|\
  29. |
  30. /
  31. """,
  32. """
  33. -------
  34. |
  35. O
  36. /|\
  37. |
  38. / \
  39. Game Over
  40. """)
  41. words = ["networking", "programming", "internet", "python", "cryptography", "ethernet", "cracker", "debugging"]
  42. answer = random.choice(words)
  43. length_word = len(answer)
  44. count = 0
  45. print "Welcome to HangMan"
  46. print "You have to guess a word as fast as possible!"
  47. print "You have only 5 tries"
  48. print
  49. guess = raw_input("\nWhat's your guess: ")
  50. guess = guess.lower()
  51. while guess != answer:
  52. if count == 0:
  53. print "\n\nWRONG!!"
  54. print hangman[0]
  55. if count == 1:
  56. print "\n\nWRONG!!"
  57. print hangman[1]
  58. if count == 2:
  59. print "\n\nWRONG!!"
  60. print "I will give you a hint, length of the word is ", length_word
  61. print hangman[2]
  62. if count == 3:
  63. print "\n\nWRONG!!"
  64. print "length of the word is ", length_word
  65. print "and it starts with ", answer[0:1]
  66. print hangman[3]
  67. if count == 4:
  68. print "\n\nWRONG!!"
  69. print "length of the word is ", length_word
  70. print "and it's start with ", answer[0:1]
  71. print "alright! this is the last chance, it starts with :", answer[0:1], answer[1:2], answer[2:3], "......................"
  72. print hangman[4]
  73. if count == 5:
  74. print "\n\t\tGAME OVER"
  75. print "The correct answer is ", answer
  76. break
  77. guess = raw_input("\nWhat's your guess: ")
  78. guess = guess.lower()
  79. count += 1
  80. if guess == answer:
  81. print "\nCongratulation, you took only ", count, "tires"
  82. print "thanks for playing"
  83. raw_input()

comments powered by Disqus