'''
In a game of Lingo, there is a hidden word, five characters long. The object of the game is to find this word by guessing, and in return receive two kinds of clues: 1) the characters that are fully correct, with respect to identity as well as to position, and 2) the characters that are indeed present in the word, but which are placed in the wrong position. Write a program with which one can play Lingo. Use square brackets to mark characters correct in the sense of 1), and ordinary
parentheses to mark characters correct in the sense of 2). Assuming, for example, that the program conceals the word "tiger", you should be able to interact with it in the following way:

import lingo
snake
Clue: snak(e)
fiest
Clue: f[i](e)s(t)
times
Clue: [t][i]m[e]s
tiger
Clue: [t][i][g][e][r]
'''

import random

#helper function
def lingo():
    guess = ''
    fp = open("lingo.txt","r")
    words = []
    word = ''
    new = ''


    for line in fp:
        words.append(line.strip())

    word = random.choice(words)

    guess = raw_input("Enter a guess: ")

    while(guess != word):
        new = ''
        for g in guess:
            if g in word:
                if word.find(g) == guess.find(g):
                    new = new + "[" + g + "]"
                else:
                    new = new + "(" + g + ")"
            else:
                new = new + g

        guess = raw_input("clue: " + new + "\n")



#main function
if __name__ == "__main__":
    print("Enter word of length 5")
    lingo()
