I'm having some trouble working on a basic program I'm making whilst I try and learn Python, the problem is I am trying to compare a users input to a variable that I have set and it is not working when I try and compare them.
This is the loop in question:
if del_question == "1":
symbol = input("What symbol would you like to change?: ")
while len(symbol) != 1 or symbol not in words:
print("Sorry, that is not a valid symbol")
symbol = input("What symbol would you like to change?: ")
letter = input("What would you like to change it to?: ")
while letter in words and len(letter) != 1:
print("Sorry, that is not a valid letter")
letter = input("What letter would you like to change?: ")
dictionary[symbol] = letter
words = words.replace(symbol, letter)
print("Here is your new code: \n", words)
The game is about breaking the code by pairing letters and symbols, this is where the letters and symbols are paired but on the letter input when I try and make it so that you are unable to pair up the same letter twice it simply bypasses it. It is working on the symbol input but I'm not sure on why it's not working here.
Here is the text file importing:
code_file = open("words.txt", "r")
word_file = open("solved.txt", "r")
letter_file = open("letter.txt", "r")
and:
solved = word_file.read()
words = code_file.read()
clue = clues_file.read()
This is the contents of the words file:
#+/084&"
#3*#%#+
8%203:
,1$&
!-*%
.#7&33&
#*#71%
&-&641'2
#))85
9&330*