#random functions imported
import random
import string
def welcome(begin):
title = "Welcome To This Hangman Game"
if begin == "yes":
print
print "*"+"-"*len(title)+"*"
print "|"+title+"|"
print "*"+"-"*len(title)+"*"
return True
else:
print "\nBye For Now!"
return False
def getWords(filename):
newList = []
fileIn = open("listOfFruits.txt", "r")
for everyLine in fileIn:
temp = everyLine.split()
newList.append(temp)
everyLine.strip("\n")
fileIn.close()
return newList
def chooseWord(newList):
mysteryWord = random.choice(newList)
newList.remove(mysteryWord)
for word in mysteryWord:
for letter in word:
print "_",
print "\n"
print word
return mysteryWord
return word
def guessWord(word):
guessMade = ""
while
#MAIN#
######
#1 - welcome
begin = raw_input ("Would you like to start this Game - [yes/no]: ")
returnValue = welcome(begin)
while returnValue != True:
exit
#2 - getWords
newList = getWords("listOfFruits.txt")
#3 - chooseWord
word = chooseWord(newList)
##
###4 - guessWord
guessWord(word)
This post has been edited by Simown: 23 February 2012 - 04:14 PM
Reason for edit:: please use code tags!

New Topic/Question
Reply



MultiQuote



|