1 the computer displays some secret word(in underscore):---
2 I guess letter"c"in the word
3 yes,the screen pops up like this :c--
4 I guess the second letter is u
5 yes , it is :cu-
6 last ,I guess the final one is p
7 yes , it is :cup

WHICH FUNCTION SHALL I USE TO MAKE THIS HAPPEN?
The topic will be asked in tomorrow , could anyone give me some hint or related example?

Thank you!:)

Recommended Answers

All 3 Replies

You need to show some effort, but first think about what's happening, obviously it knows the LENgth of the word and displays dashes for letters that haven't been guessed and IF the letter guessed is IN the word then it will show that letter. You need to make the function, show us some work and we'll likely help with more specific issues.

for i in range(len(words[a]))
if word1==guessletter:
print ('The letter is in the word.')
print ('Letters matched so far:',words_so_far.replace("_",guessletter,1))

well that totally messed me up...

whats the relation ship between words[a] and word1

... lets get it strait ... you are tiring to write a HANGMAN routine ...

loop until all letters are found in word from a list of words
...show only letters in word already guessed and hide unknowns
...loop get next letter guessed
......say incorrect or correct guess letter
......until next letter is guessed in word
...until all words in list are guessed

is this close to what you are trying to do

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.