{}
run-icon
main.py
import random def scramble_word(word): """Scrambles the letters of a word""" scrambled = list(word) random.shuffle(scrambled) return ''.join(scrambled) def word_scramble_game(): words = ["python", "computer", "programming", "developer", "keyboard", "internet", "software"] secret_word = random.choice(words) scrambled_word = scramble_word(secret_word) print("🔠 Welcome to the Word Scramble Game!") print(f"Can you guess the original word from this scrambled version? {scrambled_word}") attempts = 0 while True: guess = input("Your guess: ").lower() attempts += 1 if guess == secret_word: print(f"🎉 Correct! You guessed it in {attempts} attempts!") break elif guess == "quit": print(f"😢 You quit! The word was '{secret_word}'.") break else: print("❌ Wrong guess! Try again or type 'quit' to exit.") word_scramble_game()
Output