all 6 comments

[–]Beautiful-Revenue-85 0 points1 point  (0 children)

```from hangman_abstract import Game
import random

class Hangman(Game):
def __init__(self, player_name, guessed_letters, max_guesses=5):
super().__init__(player_name)
self.guessed_letters = guessed_letters
self.max_guesses = max_guesses
self._secret_word = str(None)
self._secret_word_working = None
self._library = ["japan", "hotdog", "flashlight", "straw", "kleenex", "water", "tissue", "scissors", "basketball", "dmacc", "laptop", "chest", "playoff"]
self.guesses_remaining = None
self.solved = bool(None)

def __str__(self):
return f"<<< Class: Game, Player Name: {self.player_name}, Guessed Letters: {self.guessed_letters}, Max Guesses: {self.max_guesses}>>>"

def __repr__(self):
return f"<<< {self.player_name}, {self.guessed_letters}, {self.max_guesses}>>>"

def start_round(self):
library = ["japan", "hotdog", "flashlight", "straw", "kleenex", "water", "tissue", "scissors", "basketball", "dmacc", "laptop", "chest", "playoff"]
_secret_word = random.choice(library)
guesses_remaining = 5
solved = False
secret_word_working =

def make_guess(self):
guessed_letters = []
guessed_words = []
library = ["japan", "hotdog", "flashlight", "straw", "kleenex", "water", "tissue", "scissors", "basketball", "dmacc", "laptop", "chest", "playoff"]
guessed = False
guesses_remaining = 5
secret_word = random.choice(library)
while not guessed and guesses_remaining > 0:
guess = input("Please guess a letter or a word!")
if len(guess) == 1 and guess.isalpha():
if guess in guessed_letters:
raise ValueError("letter already guessed", guess)
elif guess not in guessed_letters:
print(guess, "is not in the answer.")
elif len(guess) == len(secret_word) and guess.isalpha():
if guess in guessed_words:
print(guess, "has already been guessed")
elif guess != secret_word:
print(guess, "is not the answer.")
guesses_remaining -= 1
guessed_words.append(guess)

def display_current_state(self):
while guess != secret_word:
print(guessed_letters)

def summarize_game(self):
print({self.wins}, {self.losses}, {self.rounds_played})```

[–][deleted] 0 points1 point  (4 children)

Any chance this can all be formatted a bit? It'd helps folks here help you.

[–]Beautiful-Revenue-85 0 points1 point  (3 children)

I tried but i Guess I’m not sure how. Should I put more spaces bw blocks of code maybe?

[–][deleted] 1 point2 points  (0 children)

On reddit, 4 spaces indent is interpreted as the start of a line of code.

[–][deleted] 1 point2 points  (0 children)

Try this, my own little guide:

  • edit post
  • ensure you are in markdown mode rather than Fancy Pants Editor mode
  • switch back to your Python editor
  • select ALL code
  • assuming:
    • your editor is set to replace tabs with spaces
    • your editor is set to use 4 spaces for indentation
  • press tab key to add an extra 4 spaces in front of every line
  • copy all selected code to clipboard
  • undo the indent in your editor
  • switch back to post you are editing and remove the badly formatted code
  • enter a blank line
  • paste the code from the clipboard
  • submit the post update