#Word Jumble Game
import random
import string
def jumbled():
words = ['Jumble', 'Star']#, 'Candy', 'Wings', 'Power', 'String', 'Shopping', 'Blonde', 'Steak', 'Speakers', 'Case', 'Stubborn', 'Cat', 'Marker', 'Elevator', 'Taxi', 'Eight', 'Tomato', 'Penguin', 'Custard']
count = 0
loop = True
loop2 = True
while loop:
word = string.lower(random.choice(words)
jumble = list(word)
random.shuffle(jumble)
scrambled = "".join(jumble)
while loop2:
print '\n',scrambled,'\n'
guess = raw_input('Guess the word: ')
quit = set(['quit','Quit'])
choice = 'quit'
if guess.lower() == word:
print '\nCorrect!'
count+=1
print "You took",count,"trie(s) in order to get the right answer",jumbled()
else:
print '\nTry again!\n'
count+=1
if count == 3:
if words[0]*2:
print "It looks like you're having trouble!"
print 'Your hint is: %s'(words) # I'm trying to pull a word from the above list here.
jumbled()
So here I am, playing a game I've programmed that chooses a random word from the list, mixes it up then I have to correctly guess it. This process works and if I get it wrong, I will get a message saying to try again and if correct, will congratulate me then onto the next word!
A problem I'm having is that I want to be able to give a hint if the user incorrectly guesses after 3 times. However, if the program gives me, say 'jumble' as a word that I have to guess and I guess it wrong 3 times, I would like a hint based off that word. I can't get the word star then a hint that has to do with jumble, can I?
With the code I have now (I have commented what line I'm having trouble with), I get an error saying that the string is not callable, I don't know what to call...
Please help!
If it's not too much trouble, I also need to be able to type in quit then the game would quit itself, unfortunately, I don't know how to do this.
Thanks in advance!
You have the unjumbled word in word
so you could for example use
print 'Your hint is: %s'%word
Very easy hint though
You could make a dict
to map words to clues eg
hint_dict = {'Jumble': 'Name of this game.", "Star": ...}
and then use
print 'Your hint is: %s'%hint_dict[word]