PHow do we improve the word jumble game so that each word is paired with a hint. if the player enters hint then the program should display the corresponding hint using a nested sequence to store the words and hint.

Hint ...

''' word_scramble_hint101.py
create a scrambled/jumbled word that has a hint associated with it
'''

import random

# a list of (word, hint) tuples
word_hint = [
('mouse', 'eats cheese'),
('automobile', 'uses petrol'),
('boat', 'floats on water')
]

# shuffle word_hint list in place and pick a random word and its hint
random.shuffle(word_hint)
word = word_hint[0][0]
hint = word_hint[0][1]

# scramble word via list of char
char_list = list(word)
random.shuffle(char_list)
scramble = "".join(char_list)

# show possible result
print("scramble = {}\nhint = {}".format(scramble, hint))

''' possible result ...
scramble = otab
hint = floats on water
'''
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.