相关疑难解决方法(0)

随机字生成器 - Python

所以我基本上正在开发一个项目,在这个项目中,计算机从一个单词列表中取出一个单词并为用户弄乱它.只有一个问题:我不想继续在列表中写出大量的单词,所以我想知道是否有办法导入大量的随机单词,所以即使我不知道它是什么,并且然后我也可以享受游戏了?这是整个程序的编码,它只有6个单词,我输入:

import random

WORDS = ("python", "jumble", "easy", "difficult", "answer",  "xylophone")
word = random.choice(WORDS)
correct = word
jumble = ""
while word:
    position = random.randrange(len(word))
    jumble += word[position]
    word = word[:position] + word[(position + 1):]
print(
"""
      Welcome to WORD JUMBLE!!!

      Unscramble the leters to make a word.
      (press the enter key at prompt to quit)
      """
      )
print("The jumble is:", jumble)
guess = input("Your guess: ")
while guess != correct and guess != "":
    print("Sorry, that's not it")
    guess …
Run Code Online (Sandbox Code Playgroud)

python random python-3.3

26
推荐指数
3
解决办法
8万
查看次数

标签 统计

python ×1

python-3.3 ×1

random ×1