Can the following complete program be improved? I have been using the Python For Absolute Beginners book and recently made my own version of the Python Word Jumble game.
The Areas I am particularly interested in improving:
- The while word Loop Block
- Python Standards
- Simplifying the overall program
# Word Jumble Game. Using Mac0S (Latest). Python V 3.4.3 import random # Initialize Variables WORD = ('python', 'programming', 'mug', 'glass','phone') # Constant Variable word = random.choice(WORD) correct = word jumble = '' guess = '' print('\t\tWelcome to Word Jumble!') print('\n') print('\tUnscramble the letters to make a word.') while word: position = random.randrange(len(word)) jumble += word[position] # Jumble process 1 word = word[:position] + word[(position + 1):] #Jumble process 2 print('\n') print('The Jumble is:', jumble) guess = input('Your Guess: ') while guess != correct: print('Sorry, that\'s not it') guess = input('Your Guess: ') if guess == correct: print('\n') print('That\'s it! You guessed it!') print('\n') print('Thanks for playing') exit() # User has the correct answer