Created
          August 4, 2021 05:38 
        
      - 
      
- 
        Save Joshbeyer/a2a500ad2bc7094118e05b4f35eff301 to your computer and use it in GitHub Desktop. 
    Simple hangman game
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import random | |
| word_list = ["aardvark", "baboon", "camel"] | |
| chosen_word = random.choice(word_list) | |
| word_length = len(chosen_word) | |
| print(f'Pssst, the solution is {chosen_word}.') | |
| display = [] | |
| for _ in range(word_length): | |
| display += "_" | |
| while "_" in display: | |
| guess = input("Guess a letter: ").lower() | |
| for position in range(word_length): | |
| letter = chosen_word[position] | |
| # print(f"Current position: {position}\n Current letter: {letter}\n Guessed letter: {guess}") | |
| if letter == guess: | |
| display[position] = letter | |
| print(display) | |
| print("You successfully guessed every word. You Win.") | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment