用户:
誓焰查看:0 回复:0 评论:0 创建时间:2023-11-17T23:37:31
【作品展示】

【作品介绍】
自己慢慢看我的注释,超级详细,这个程序超级简单,要搬运记得@我下,谢谢
【作品源代码】
import random
# 生命次数
lives = 3
# 神秘单词, 随机选择
words = ['pizza', 'fairy', 'teeth', 'shirt', 'otter', 'plane'] # 可以修改内容增加玩法
secret_word = random.choice(words)
# print(secret_word)
clue = list('?????')
heart_symbol = u'\u27喵'
guessed_word_correctly = False
def update_clue(guessed_letter, secret_word, clue):
index = 0
while index < len(secret_word):
if guessed_letter == secret_word[index]:
clue[index] = guessed_letter
index = index + 1
while lives > 0:
print(clue)
print('剩余生命次数: ' + heart_symbol * lives)
guess = input('猜测字母或者是整个单词: ')
if guess == secret_word:
guessed_word_correctly = True
break
if guess in secret_word:
update_clue(guess, secret_word, clue)
else:
print('错误。你丢了一条命\n')
lives = lives - 1
if guessed_word_correctly:
print('你赢了! 秘密单词是 ' + secret_word)
else:
print('你输了! 秘密单词是 ' + secret_word)
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn