Upload
phungbao
View
217
Download
0
Embed Size (px)
Citation preview
‘Guess the word’ game
...aka hangman without the hangman
You will need the following functions (in order of difficulty):
inWord(letter,word) – (Boolean) Decides whether letter is in word
timesInWord(letter,word) – (Integer) Counts how many times a letter
is in a word
getLetter() – (String) Asks the user to enter a letter. Checks whether this
letter is actually a letter (i.e. not a number) and that it is only one letter (i.e.
not 2 or more letters).
printWord(word, guesses) – (Void) Takes a word letter by letter and
either prints the letter (if this letter is in the guesses list) or an underscore (if it
is not in the list)
checkWin(word,guesses) – (Boolean) For each letter in the correct
guesses list, this function counts how many times it is used in the word. It adds
all of the correct guesses up and checks whether this number is equal to the
length of the word or not.
Your program will then be very simple to write...
- Use the wordgameskeleton.py as a basis for your code
Extensions 1. If they guess a letter that has already been added to the correctGuesses list then tell them
and do not add it to the list again
2. Add a counter to count how many guesses they have used
3. Add a guess limit so the game will end if they go over 10 guesses
4. Add an incorrectGuesses list and if their guess was wrong, add it to this list