Game Development Reference
In-Depth Information
39. /|\ |
40. |
41. |
42. =========''', '''
43.
44. +---+
45. | |
46. O |
47. /|\ |
48. / |
49. |
50. =========''', '''
51.
52. +---+
53. | |
54. O |
55. /|\ |
56. / \ |
57. |
58. =========''']
59. words = 'ant baboon badger bat bear beaver camel cat clam
cobra cougar coyote crow deer dog donkey duck eagle ferret
fox frog goat goose hawk lion lizard llama mole monkey
moose mouse mule newt otter owl panda parrot pigeon python
rabbit ram rat raven rhino salmon seal shark sheep skunk
sloth snake spider stork swan tiger toad trout turkey
turtle weasel whale wolf wombat zebra'.split()
60.
61. def getRandomWord(wordList):
62. # This function returns a random string from the
passed list of strings.
63. wordIndex = random.randint(0, len(wordList) - 1)
64. return wordList[wordIndex]
65.
66. def displayBoard(HANGMANPICS, missedLetters,
correctLetters, secretWord):
67. print(HANGMANPICS[len(missedLetters)])
68. print()
69.
70. print('Missed letters:', end=' ')
71. for letter in missedLetters:
72. print(letter, end=' ')
73. print()
74.
75. blanks = '_' * len(secretWord)
76.
77. for i in range(len(secretWord)): # replace blanks with
correctly guessed letters
78. if secretWord[i] in correctLetters:
79. blanks = blanks[:i] + secretWord[i] + blanks
[i+1:]
80.
81. for letter in blanks: # show the secret word with
spaces in between each letter
Search WWH ::




Custom Search