इसलिए मैं मूल रूप से एक प्रोजेक्ट पर काम कर रहा हूं जहां कंप्यूटर शब्दों की सूची से एक शब्द लेता है और उपयोगकर्ता के लिए इसे जुम्बल करता है। केवल एक समस्या है: मैं सूची में बहुत से शब्दों को लिखना नहीं चाहता हूं, इसलिए मैं सोच रहा हूं कि यादृच्छिक शब्दों का एक टन आयात करने का कोई तरीका है, इसलिए मुझे नहीं पता कि यह क्या है, और तो मैं भी खेल का आनंद ले सकता था? इस पूरे कार्यक्रम की कोडिंग है, यह केवल 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")
शब्दों का एक पाठ फ़ाइल का उपयोग में नाम ऑनलाइन शब्द मिलता है? '/ usr/share/dict/words' आम है * निक्स प्लेटफ़ॉर्म, या अन्य वर्डलिस्ट्स जिनका आप उपयोग कर सकते हैं ... –
[संभवतः उपयोग के लिए निशुल्क शब्द सूची का संभावित डुप्लिकेट?] (http://stackoverflow.com/questions/ 772 9 22/फ्री-वर्ड-लिस्ट-फॉर-यूज-प्रोग्रामेटिकली) – Bakuriu