Game Development Reference
In-Depth Information
9 - Hangman
Hangman's Source Code
This chapter's game is a bit longer than our previous games. You can either type in the
code below directly into the file editor (which I recommend) or you can obtain the code
from this topic's website. To grab the code from the web, in a web browser go to the URL
http://inventwithpython.com/chapter9 and follow the instructions for downloading the
source code.
hangman.py
This code can be downloaded from http://inventwithpython.com/hangman.py
If you get errors after typing this code in, compare it to the topic's code with the online
diff tool at http://inventwithpython.com/diff or email the author at
al@inventwithpython.com
1. import random
2. HANGMANPICS = ['''
3.
4. +---+
5. | |
6. |
7. |
8. |
9. |
10. =========''', '''
11.
12. +---+
13. | |
14. O |
15. |
16. |
17. |
18. =========''', '''
19.
20. +---+
21. | |
22. O |
23. | |
24. |
25. |
26. =========''', '''
27.
28. +---+
29. | |
30. O |
31. /| |
32. |
33. |
34. =========''', '''
35.
36. +---+
37. | |
38. O |
Search WWH ::




Custom Search