

Link: http://codepad.org/EOczcgUr raw code | fork ]



Python , pasted on Dec 8:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 ''' Created on Dec 7, 2011 @author: Kurt ''' import random import string wrong_letters = [] right_letters = [] words = [ "cat" , "dog" ] word = words [ random . randint ( 0 , len ( words ))] gameover = False def guess (): letter = raw_input ( "Letter: " ) if not letter in word : wrong_letters . append ( letter ) if letter in word : right_letters . append ( letter ) print "You have %s right." % string . join ( right_letters , " " ) print "You have %s wrong." % string . join ( wrong_letters , " " ) if string . join ( right_letters , "" ) == word : print 'You win!' gameover = True if len ( wrong_letters ) == 6 : print 'You lose...' print 'The word was %s .' % word gameover = False while gameover != True : guess ()