import
random
def
checkguess(guessword,maskString,userinput):
updateStr
=
""
for
i
in
range
(
0
,
len
(guessword)):
if
guessword[i]
=
=
userinput:
updateStr
=
updateStr
+
updateStr[i]
else
:
updateStr
=
updateStr
+
maskString[i]
return
updateStr
def
q4():
wordlist
=
"meringue foulard eudaemonic narcolepsy vivisepulture pococurante albumen cymotrichous malfeasance "
words
=
wordlist.split()
index
=
random.randint(
0
,
len
(words)
-
1
)
print
(words[index])
guessword
=
words[index]
lettercount
=
len
(words[index])
maskString
=
"_ "
*
len
(words[index])
print
(
"The word {:} has {:} letters . Spell it in 5 tries."
.
format
(maskString,lettercount ))
currentTry
=
1
while
currentTry <
6
:
print
(
"Try {} - Current :{}"
.
format
(currentTry,maskString))
userinput
=
eval
(
input
(
"your guess ? : "
))
maskString
=
checkguess(guessword,maskString,inputData)
currentTry
+
=
1
if
maskString
=
=
guessword:
break
print
(
"correct the words is :"
,guessword)
q4()