Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 9357

A common word-guessing game, usually involving a pictorial representation of a stick figure being hanged, progressively rendered for each wrong guess

6 votes

"Hangman" game follow-on

Just a nitpick on your random word choice routine, which is: /* * Returns a random word to guess and play. */ private String getRandomWordToGuess() { // Load a word from dictionary. To do: Imp …
200_success's user avatar
5 votes
Accepted

Completed Hangman game

.*; public class HangMan { private static final String[] VOCABULARY = new String[] { "peace", "nuts", "dankmemes", "fizz", "awesome" }; private static Scanner input = new Scanner( … This is a hangman game! …
200_success's user avatar
2 votes

Display command-line Hangman

You can effectively compress the data by defining two strings, representing a format and a mask. private static final String IMG_FMT = " ________%n" + " | \\|%n" + " o …
200_success's user avatar
4 votes

Console based Hangman in Java

Nitpick: the variable P1 should be named p1, since the convention is to use uppercase for class names and constants. I agree with @Josay that this function desperately needs to be broken up! Since y …
200_success's user avatar
2 votes

Hanging men efficiently

This code in makePhrase() should be a switch block: if (phraseType == 1) { ... } else if (phraseType == 2) { ... } else if (phraseType == 3) { ... } Within the phraseType == 2 case, you …
200_success's user avatar
10 votes
Accepted

Python Hangman program

For me, part of the fun of playing Hangman is to see the final state of the game, and clearing the screen denies me that pleasure. … def play(word): """ Play one game of Hangman for the given word. …
200_success's user avatar
8 votes
Accepted

First Hangman game

See other examples of code with this problem: Hangman Number-guessing game Rock-paper-scissors Mileage calculator Here is an implementation restructured to use functions properly. … wrong_guesses = [guess for guess in guesses if not guess in secret] return len(wrong_guesses) >= len(HANGMANPICS) def play_hangman(): """Play one game of hangman. …
200_success's user avatar
2 votes

First Hangman game

Some issues in create_hangman(): To pick a word from a list, use random.choice(). Global variables are bad. Game state information, such as the current secret word, should be stored in the stack or …
200_success's user avatar
8 votes
Accepted

Hangman implementation for teaching a Python course

Y/n ").lower() def game(): """ Play a single game of Hangman. … print("\nThe secret word was {}".format(secret_word.upper())) return False def main(): """ Play games of Hangman until the user decides to quit. """ while True: …
200_success's user avatar
6 votes

Python Hangman Console

File input If you want the lowercase alphabet, use string.ascii_lowercase. Calling open() like that, with no corresponding close(), could be a file descriptor leak. You're almost always better off …
200_success's user avatar
9 votes

Find all words that satisfy unknown letters (Hangman)

The solution would indeed be much simpler using regular expressions. The trick is to build the regular expression dynamically, using a negated character class like [^unwanted] to represent any charac …
200_success's user avatar