python猜单词游戏

  • Post author:
  • Post category:python


import random
word=['hello','write','blue','shit','double']
word=random.choice(word)
answer=word
jumble=""
index=random.randrange(len(word))
jumble+=word[index]
word=word[0:index]+word[(index+1):]
print("打乱后的单词:",jumble)
guess=input("请输入要的单词")
if guess == answer:
    print("猜对了")
else:
    print("猜错了")
    while guess!=answer:
        guess=input("错了,请重新输入:")
        print("猜对了")
        flag=input("是否继续(Y/N)")
        print("Game over!")



版权声明:本文为YuebaiTA原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。