import random #随机函数
words =("conscietious","noteworthy")
i = random.randint(0,len(words)-1) #随机单词的下标
b = list(words[i]) #将单词(字符串)转换成列表
random.shuffle(b) #打乱字符列表的顺序
for j in range(len(b)):
print("{} ".format(b[j]),end='')
if j + 1 >= len(b):
print()
a = input("Please input the word : ")
while a != ' ':
if a == words[i]:
print('Congratulation!\nGuess right!the word is "{}"'.format(words[i]))
c = input("Do you want continue guess words?\ny:yes;n:no\nPlease choose: ")
print()
if c == "y" or c == "yes" :
i = random.randint(0,len(words)-1)
b = list(words[i])
random.shuffle(b)
猜单词游戏。计算机随机产生一个单词,打乱字母顺序,供玩家去猜 a.准备一组单词,随机抽取一个b.将抽取的单词作为答案,打乱字母顺序,显示给玩家,供其猜测c.猜测错误继续猜测或以空字符串.
最新推荐文章于 2024-03-27 11:07:24 发布