示例#1
0
def hangman():
    guesses = []
    d = dict.get_dictionary()
    w = random.choice(d)
    nleft = 6
    for i in w:
        print "_",
    print
    while True:
        hangman_graphic(6-nleft)
        guess = raw_input("what is your guess? ")
        if guess in guesses:
            print "you already guessed that"
            continue
        guesses.append(guess)
        nmatch = 0
        for c in w:
            if c in guesses:
                print c,
                nmatch += 1
            else:
                print "_",
        print
        if guess not in w:
            print "incorrect"
            nleft -= 1
            print "you have",
            print nleft,
            print "wrong guesses left"
        if nmatch == len(w):
            print "you win!"
            break
        if nleft == 0:
            print "you lose!"
            print w
            break
示例#2
0
import dict

x = 0
for i in dict.get_dictionary():
    if len(i) > x:
        x = len(i)
        print i
print x
示例#3
0
import dict
import random

words = dict.get_dictionary()

w = random.choice(words)

while True:
    g = raw_input('Guess: ')
    if  g not in words:
        print g+' is not a word'
        continue