文字游戏:
1.玩家1挑选一个秘密单词,单词中有多少个字母则画多少个下划线
2.玩家二每猜一个字母,若正确则将下划线改为字符,若同一字母出现两次则需要猜测两次
3.玩家二共有单词长度+3次机会,若猜测正确则玩家二胜利,否则玩家1胜利
words=input("please input one secret words")
words1=words
lines=[]
while len(lines)<len(words):
lines.append("_")
count=0
while count<len(words)+3:
x = input("please input one word")
if x in words1:
i = words1.find(x)
lines[i] = x
words1=words1.replace(x,"_",1)
answ = "".join(lines)
print("Your answer is",answ)
else:
print("you're wrong")
count=count+1
if answ==words:
print("You win")
break
if answ!=words:
print("Game Over")