View Single Post
Old May 11th, 2006, 12:06 AM   #3
hydroxide
Programmer
 
Join Date: Apr 2005
Posts: 73
Rep Power: 4 hydroxide is on a distinguished road
The logic could be _much_ simpler if you processed your two lists as follows. The code is VERY rough - just to give the idea. Actual correct implementation is left as an exercise ;-)
solution = list(word)
current = ["_"] * len(word)
guessed = set()

def replace_if_ok(sollet, currlet, letter):
    if sollet == letter:
        return sollet
    else:
        return currlet
while lives:
    if letter in guessed:
        handle_it()
    elif letter not in solution:
        do_something()
    else:
        current = [replace_if_ok(sollet, currlet, letter)
                       for sollet, currlet in zip(solution, current)]
    guessed.add(letter)
    print " ".join(current)
hydroxide is offline   Reply With Quote