单词连猜,技术还不够,不喜勿喷。
其实早就做出来了,但只是之前做的我自己都看不懂,现在无聊就又做了一编,望大家能多多指教{:10_254:} :import random
words = ["see","low","row","cow","new","car"]
word = random.choice(words)
list1 = ["?"] * len(words)
lives = 9
index = -1
help_turns = len(word) // 2
live_picture = u"\u2764" #设置爱心图像
score = 0
right = 0
print(list1)
print("还剩生命值:",lives * live_picture)
while lives != 0 and list1 != " ".join(word).split():
answer = input("猜一个在某个单词中出现的字母:")
if answer in " ".join(word).split(): #如果猜的字母在单词中
index = word.find(answer,index + 1) #设置index + 1 作为寻找起始范围,防止遇到"see"这类重复字母单词
list1 = answer
right += 1
elif answer == "场外援助" and help_turns > 0: #如果用户申请场外援助并还有场外援助的机会
help_alpha = int(input("请问您要揭示第几个字母:")) - 1
list1 = word
print("现在场外援助次数还剩{}次".format(help_turns))
help_turns -= 1
elif answer == "场外援助" and help_turns == 0: #如果用户想要申请场外援助但却已用完了机会
print("场外援助次数还剩 0 次!")
answer = input("猜一个在某个单词中出现的字母:")
while answer == "场外援助": #重复直至再次输入的不是"场外援助",因为已经没有援助的机会了
print("场外援助次数还剩 0 次!")
answer = input("猜一个在某个单词中出现的字母:")
if answer in " ".join(word).split():
index = word.find(answer,index + 1)
list1 = answer
right += 1
else:
print("猜错了,扣除一颗生命值!")
lives -= 1
help_turns -= 1
else: #猜的字母不在单词中
print("猜错了,扣除一颗生命值!")
lives -= 1
print(list1)
print("还剩生命值:",lives * live_picture)
score = right * len(word) * (help_turns + 1) * lives #得到用户成绩
all_score = len(word) * len(word) * (len(word) // 2 + 1) * len(word) #得到总成绩
score = score / (all_score / 100) #见下方注释,与总成绩一起变化
all_score = all_score / (all_score / 100) #将总成绩变成 100 分
if lives > 0:
print("你赢了!恭喜你在这次竞赛中获得了{}分,满分{}分!".format(score,all_score))
else:
print("你输了!正确答案是:{},恭喜你在这次竞赛中获得了{}分,满分{}分!".format(word,score,all_score))
{:5_106:} 对了,输入 "场外援助" 可以作弊,
当然,我说的 "场外援助" 是不带引号的 : 场外援助 哇哦{:9_236:} 我顶! {:5_95:} {:7_146:} 我又来怼BUG啦
看图:{:10_256:}
好玩不? {:10_254:} 写的bug太多了。。。建议测试一下再发出来
页:
[1]