FiddleComputers

Shuffle Word game

Mar 17th, 2019
83
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #coding: utf8
  2.  
  3. from random import randint
  4.  
  5. guessWord = str(raw_input("Enter the word to guess: "))
  6. tries = 0
  7.  
  8. shuffledGuessWord = ""
  9. keyUsed = []
  10.  
  11. while len(shuffledGuessWord) != len(guessWord):
  12.     keyAlreadyInArray = False
  13.     key = randint(0, len(guessWord)-1)
  14.     for i in range(0, len(keyUsed)):
  15.         if key == keyUsed[i]:
  16.             keyAlreadyInArray = True
  17.  
  18.     if not keyAlreadyInArray:
  19.         shuffledGuessWord += guessWord[key]
  20.         keyUsed.append(key)
  21.  
  22. print shuffledGuessWord
  23.  
  24. while str(raw_input("Enter the right word: ")) != guessWord:
  25.     tries += 1
  26.     print("Wrong word!")
  27.     print ("Try #"+str(tries))
  28.  
  29. print("You found the right word! It was indeed "+guessWord)
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×