Hang XXX
Hang XXX
Hang XXX
# -----------------------------------
# Helper code
# You don't need to understand this helper code,
# but you will have to know how to use the functions
# (so be sure to read the docstrings!)
import random
WORDLIST_FILENAME = "words.txt"
def loadWords():
"""
Returns a list of valid words. Words are strings of lowercase letters.
def chooseWord(wordlist):
"""
wordlist (list): list of words (strings)
def getAvailableLetters(lettersGuessed):
'''
lettersGuessed: list, what letters have been guessed so far
returns: string, comprised of letters that represents what letters have not
yet been guessed.
'''
# FILL IN YOUR CODE HERE...
avaiableAlphabet = 'abcdefghijklmnopqrstuvwxyz'
alphabetTab=list(avaiableAlphabet)
newAlphabet = ''
for i in range(0, len(lettersGuessed)):
alphabetTab.remove(lettersGuessed[i])
return newAlphabet
def hangman(secretWord):
'''
secretWord: string, the secret word to guess.
* At the start of the game, let the user know how many
letters the secretWord contains.
* Ask the user to supply one guess (i.e. letter) per round.
* After each round, you should also display to the user the
partially guessed word so far, as well as letters that the
user has not yet guessed.
# When you've completed your hangman function, uncomment these two lines
# and run this file to test! (hint: you might want to pick your own
# secretWord while you're testing)
my_word = 'Antalek'
secretWord = my_word.lower()
# secretWord = chooseWord(wordlist).lower()
#hangman(secretWord)
getAvailableLetters( ['b', 'd', 'c', 'x', 'y', 'z' ])