我不明白为什么该部分not_com_word
不将猜测的字符打印在一起。现在在猜测函数的每个循环中not_com_word
,代表未完成的单词必须一起显示猜测的字符和左侧隐藏的字符。
# Country Guess game produced by Farzad YZ
import random
import string
print '**Guessing game [Country version]---Powered by Farzad YZ**'
seq = ['iran','iraq','england','germany','france','usa','uruguay','pakistan']
choice = random.choice(seq)
length = len(choice)
print 'The hidden word is:',length*'*'
def guess():
while 1:
not_com_word = ''
i = raw_input('Guess the character in turn: ')
if i == choice[g]:
print 'That is right!'
not_com_word = not_com_word + i
print 'Guessed till here ->',not_com_word,((length-g-1)*'*')
break
else:
print 'Wrong! Try again.'
continue
g = 0
while g < length:
guess()
if g == length-1:
print '''Congratulations! You guessed the country finally.
The country was %s.''' %choice
g = g+1