だから私は基本的に、コンピューターが単語のリストから単語を取り出し、ユーザーのためにそれをごちゃまぜにするプロジェクトに取り組んでいます。1つだけ問題があります:リストに大量の単語を書き続ける必要がないので、大量のランダムな単語をインポートして、それが何であるかさえわからない方法があるかどうか疑問に思っています.私もゲームを楽しめますか?これはプログラム全体のコーディングです。私が入力した単語は 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 = input("Your guess: ")
if guess == correct:
print("That's it, you guessed it!\n")
print("Thanks for playing")
input("\n\nPress the enter key to exit")