So for my intro to programming class our final project is designing a simple game in Python. i picked Lingo but I'm running into a huge problem. Lingo is played by the computer picking a random 5 letter word (from a .txt file) then the user guessing 5 times until either they run out of guesses or get the word. It's supposed to display specific keys to help the user guess the word and this is where I'm running into problems.I've looked around the web and seen posts regarding this game using sets, zip(), etc. but we never did that in class so I have no idea how to use them. I'd be more then willing to try them if someone would be kind enough to explain them to me :). But anyways, I built my core function for the program and it works except for if the user enters a word like 'books' when the actual word is 'bones'. It picks up 'o' is in the word but can't recognize there are 2 'o's in 'books' but only one in 'bones'. So for ouput i get (B)(O)[O]K(S) instead of (B)(O)OK(S). I have no idea how to tackle this issue...any help is greatly appreciated!
if guess != realWord:
for char in guess:
if char in realWord: # It doesnt work if the letter repeats ?
if guess[0+indexValue] == realWord[0+indexValue]:
indexValue+=1
print('(', char,')')# If in correct position wrap in '()'
else:
indexValue+=1
print('[',char,']')# If in wrong position wrap in '[]'
else:
indexValue+=1
print(char)# If not in word print letter alone