Hi,
Below a part of the program I am writing, I have difficulty to make the last part function correctly.
mwodict is a dictionary where the keys are the letters of a word chosen randomly with choice method, and the values are *
The user should type a letter to try guessing the hidden word.
l is the input() letter, in case the letter typed is one of the hidden word letters, the program should return the values ‘x’ of the word except the value of l which should be replacing it’s corresponding value’’
For example:
The mwodict for the word “sifflet” should appear like this:
{'s': '*', 'i': '*', 'f': '*', 'l': '*', 'e': '*', 't': '*'}
If the user types the letter I , then my program should print as follows:
{'s': '*', 'i': **'i'**, 'f': '*', 'l': '*', 'e': '*', 't': '*'}
But the last part (print (mwodict.values().replace(’’,l))) is not returning what is expected
(Note the letter f is listed only once in the dictionary which is another issue I am trying to correct)
ty/// Variables ///
listwords=['rose','camion','partie','sifflet','coureur','fleur']
mword=choice(listwords)
motkey='*'*len(mword)
mword=list(mword)
mwordkey=list(mwrdkey)
mwodict=dict(zip(mword,mwrdkey))
/// Program ///
k=0
while k<8:
l = input("Please type a letter: \n")
lslettres = list(string.ascii_letters)
if l not in lslettres:
print("You didn't type a letter! \n")
elif l in mwodict.keys():
print (mwodict.values().replace('*',l))
k+=1pe or paste code here
BR