It works fine and meets all criteria. the problem I am having is when I try to loop the program back through it gives the same exact word from the dictionary as before, I want to to choose a different word the next time it loops.
this is what I have
thanks all!
def programIntro():
print('I will show you a scrambled word and give you three chances to')
print('guess the original word. After your second incorrect guess, I will help')
print('by providing a hint.')
print()
print('Here we go ....')
def ranWord():
word = random.choice(list(dictionary.keys()))
return word
def scramble():
daList = list(randomWord)
random.shuffle(daList)
print (''.join(daList))
import random
dictionary = {
'tuna': 'A fish',
'spoon': ' eat soup with this',
'shoe' : ' wear these on your feet',
'jacket': ' put these on during winter',
'book': ' read these',
'cup': ' drink out of these',
'keyboard': 'use these to type',
'watch': 'what time is it',
'processor': 'the central part of a computer',
'key': 'unlock things with it',
'paper': 'organic writing surface',
'ninja': 'if seen it is too late for life',
'wallet': 'hold money in this',
'speaker': 'sound comes from these',
'dinosaur': 'prehistoric badasses',
'dog': 'barks a lot',
'chair': 'makes sitting a pleasure',
'phone': 'allows you to instantly talk with people',
'sushi': 'a food from the gods discovered by the Japanese',
'printer': 'prints things',
'RAM': 'computer memory',
'wrench': 'a tool for tightening bolts',
'switch': 'turns things on or off',
'bicycle': '2 wheeled man powered vehicle', }
randomWord = ranWord()
playAgain = 'y'
while playAgain == ('y'):
programIntro()
print ('The scrambled word is... ')
scramble()
loop = 0
while loop < 3:
loop = loop +1
guess = input('what is your guess for guess number ' + str(loop) + ': ' )
print()
if guess == randomWord:
print ('Good work, your guess is correct')
break
if guess != randomWord:
print ('Sorry, that is not correct')
if loop == 2:
print("Here's a hint ----->> " + (dictionary.get(randomWord,[])) )
print()
print()
playAgain = input('Would you like to play again (y or n)?')

New Topic/Question
Reply




MultiQuote





|