Hangman Code.

trkaplan24 at gmail.com trkaplan24 at gmail.com
Thu Dec 17 08:28:23 EST 2015


Hello, I created a python code for a simple hangman game. Was wondering if anyone could edit to help me make it multiplayer so when one person guesses a letter incorrectly, the next player can then guess a letter. 

import time
player1 = raw_input("What is your name Player 1? ")
player2 = raw_input("What is your name Player 2? ")

print "Hello, " + player1, "You get to go first!"
print "Hello, " + player2, "Wait for your turn!"

print "\n"
time.sleep(1)
print "Start guessing..."
time.sleep(0.5)
word = "hockey"
guesses = ''
turns = 10
while turns > 0:
    failed = 0
    for char in word:
        if char in guesses:
            print char,
        else:
            print "_",
            failed += 1
    if failed == 0:
        print "\nYou won"
        break
    print
    guess = raw_input("guess a character:")
    guesses += guess
    if guess not in word:
        turns -= 1
        print "Wrong\n"
        print "You have", + turns, 'guesses left'
        if turns == 0:
            print "You Lose\n"

Thank you!



More information about the Python-list mailing list