Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

import random

def play_game():
word_list = {
"apple": "It's a fruit.",
"banana": "It's a yellow fruit.",
"carrot": "It's a vegetable and is orange in color.",
"dog": "It's a common pet and is known as man's best friend.",
"elephant": "It's a large mammal with a long trunk and tusks.",
"frog": "It's an amphibian that can jump and has a slimy skin.",
"giraffe": "It's a tall animal with a long neck and spots on its body.",
"hamburger": "It's a popular fast food sandwich.",
"ice cream": "It's a frozen dessert made from milk or cream.",
"jellyfish": "It's a sea creature with gelatinous and stinging tentacles.",
# Add more words and hints here
"kangaroo": "It's a marsupial native to Australia that hops on its hind legs.",
"lemon": "It's a citrus fruit with a sour taste.",
"mango": "It's a tropical fruit with a sweet and juicy flesh.",
"noodle": "It's a type of pasta made from flour, water, and sometimes eggs.",
"octopus": "It's a sea creature with eight tentacles and a soft body.",
"pizza": "It's a popular Italian dish made of a round, flat base with toppings.",
"quinoa": "It's a grain-like crop native to the Andean region.",
"raspberry": "It's a small, red fruit with a sweet and tangy taste.",
"strawberry": "It's a sweet, red fruit with seeds on its surface.",
"tomato": "It's a red, juicy fruit often used as a vegetable in cooking.",
"umbrella": "It's a device used for protection from rain or sunlight.",
"volcano": "It's a mountain that erupts molten rock, ash, and gases.",
"watermelon": "It's a large, juicy fruit with a green rind and red flesh.",
"xylophone": "It's a musical instrument with wooden bars that are struck to produce
sound.",
"yogurt": "It's a dairy product made by fermenting milk with bacteria.",
"zebra": "It's an African animal with black and white stripes.",
# Add more words and hints here
}

word = random.choice(list(word_list.keys()))
shuffled_word = ''.join(random.sample(word, len(word)))
attempts = 3

print("Welcome to the What's the Word game!")


print("Unscramble the letters to guess the word.")
print("You have 3 attempts to guess the word correctly.")

while attempts > 0:


print("\nScrambled Word:", shuffled_word)
user_guess = input("Enter your guess: ").lower()

if user_guess == word:
print("Congratulations! You guessed the word correctly!")
break
else:
attempts -= 1
print("Wrong guess. Try again!")
print("Attempts remaining:", attempts)

if attempts == 0:
print("\nGame over! You ran out of attempts.")
print("The word was:", word)

# Start the game


play_game()

You might also like