#!/usr/bin/env python
import random
kansen = 10
wordlist = []
word = "kj"
openfile = open('Woorden.txt', 'r')
while len(word) != 0:
    word = openfile.readline();
    word = word.lower()
    if len(word) != 0:
        wordlist.append(word)

wordchoise = 4 #random.randrange(0, len(wordlist), 1)
length = len(wordlist[wordchoise])
length -= 1
woordletter = []
reverter = 0
guessed = []
output = ""
while length != reverter:
    woordletter.append(wordlist[wordchoise][reverter])
    guessed.append("False")
    output += "_ "
    reverter += 1

while kansen != 0:
    print "U heeft nog " + str(kansen) + " kansen" 
    print output
    probeer = raw_input("Voer een letter in: ")
    repeat = 0
    probeer = probeer.lower()
    check = output
    output = ""
    while length != repeat:
        if (woordletter[repeat] == probeer) | (guessed[repeat] == "True"):
            output += woordletter[repeat] + " "
            guessed[repeat] = "True"
            repeat += 1
        else:
            output += "_ "
            repeat += 1
    if check == output:
        kansen -= 1
    if output.find("_") == -1:
        print "U heeft gewonnen"
        print "Het woord was: " + wordlist[wordchoise]
        input("")
        break
    
if kansen == 0:
    print "U heeft verloren"
    print "Het woord was: " + wordlist[wordchoise]
    input("")

