The wordcheck function is what is not working.
Expand|Select|Wrap|Line Numbers
- def load_words():
- '''
- Loads the words from 'words.txt' into a list,
- and returns the list. 'words.txt' must be located
- in the same directory as this program.
- '''
- wordlist = []
- inf = open('words.txt', 'r')
- for line in inf:
- w = line.strip().upper()
- wordlist.append(w)
- inf.close()
- return wordlist
- def ghost():
- wordlist = load_words()
- print (len(wordlist),"words were loaded.")
- wd=''
- n=0
- while n<3:
- if n%2 ==0:
- let = input("player 1 input a letter:")
- wd = wd + str(let[0].lower())
- n = n+1
- else:
- let = input("player 2 input a letter:")
- wd = wd + str(let[0].lower())
- n = n+1
- while n>=3:
- if n%2 ==0:
- let = input("player 1 input a letter:")
- wd = wd + str(let[0].lower())
- wordcheck(wd)
- n = n+1
- print(wd)
- else:
- let = input("player 2 input a letter:")
- wd = wd + str(let[0].lower())
- wordcheck(wd)
- n = n+1
- print(wd)
- def wordcheck(wordc):
- wordlist = load_words()
- for word in wordlist:
- count = word.count(wordc)
- if count ==1:
- print("lose")
- if wordc == word:
- print("lose")
- ghost()