Advertisement
J2112O

Python Comparision Options

Aug 12th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.40 KB | None | 0 0
  1. # my_wordscrable.py
  2. # this is the word scramble guess game with hints
  3. import random
  4. # A list of words to choose from to play the game with
  5. WORDS = ("helmet","dagger","car","oven","stroller")
  6.  
  7. # pick one word randomly from the list
  8. word = random.choice(WORDS)
  9.  
  10. # create a variable to use later to see if the guess is correct
  11. correct = word
  12.  
  13. # create a jumbled version of the word
  14. jumble =""
  15. while word:
  16.     position = random.randrange(len(word))
  17.     jumble += word[position]
  18.     word = word[:position] + word[(position) + 1:]
  19.  
  20. print("Here we go. See if you can guess the word.")
  21. print("A hint is provided but if you don't need it, then ignore..")
  22. print("The jumble is: ",jumble)
  23. if "m" in jumble:
  24.     print("This thing can protect the ole noggin..")
  25. elif "g" in jumble:
  26.     print("Some thieves use them for silent wet-work.")
  27. elif "c" in jumble:
  28.     print("Every teen hopes to get one when it is legal for them to use it.")
  29. elif "v" in jumble:
  30.     print("It's good for making cakes, pies and breads.")
  31. else:
  32.     print("Moms and nannies love these for taking the babies on walks.")
  33.  
  34.  
  35. guess = raw_input("\n\nYour guess is: ")
  36. while guess != correct and guess != "":
  37.     print("Sorry, that's not it.")
  38.     guess = raw_input("Your guess: ")
  39.  
  40.        
  41.  
  42. if guess == correct:
  43.     print("That's it! You guessed it!\n")
  44.  
  45. print("Thanks for playing.")
  46. raw_input("\n\nPress the Enter key to exit.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement