Notes

While loops -- while True Conditionals -- if_: Lists -- newlist = [], list2 = ['r','p','s'], words = ["dog", "horse"...] Iterate -- "loop over a list or string" ex. for letter in word: Append -- list.append(object) printing board -- print ''' ---- | | | | | | ----------''' Getting Input -- raw_input = ("Enter a character") Length of an object (list, string) -- if len(object) = 6 Replay -- def replay(): return raw_input("Play again? (y/n)") == "y"

Hangman

On friday, we programmed a game of hangman. Mine chose a random word from a list downloaded off the internet. Then, it took a guess of a single character from the user as input. The program then iterates that character through the correct word, and prints the character in the list of "correct characters" when it finds a match. If it doesn't find a match, the character goes into the list of incorrect characters, and the program prints the next iteration of the hangman board. After six mistakes, you lose.

These are pictures of the code for my hangman game.

This is a picture of the code for the "reader" module I made to read the dictionary text file.