Python coding problems need HELP!

This is the place for queries that don't fit in any of the other categories.

Python coding problems need HELP!

Postby TheFakePiCrew » Sun Jan 12, 2014 9:46 am

Hi i'm relatively new to python and i'm struggling a bit please could somebody tell me what is wrong with this Hangman script.
Code: Select all
#importing the time module
import time
#welcoming the user
name = raw_input('What is your name?')
print 'Hello, + name, Time to play hangman!'
print "\n"
#wait for 1 second
print 'Start guessing...'
#here we set the secret
word = 'secret'
#creates an variable with an empty value
guesses = ''
#determine the number of turns
turns = 10
# Create a while loop
#check if the turns are more than zero
while turns > 0:         
    # make a counter that starts with zero
    failed = 0             
    # for every character in secret_word   
    for char in word:     
    # see if the character is in the players guess
        if char in guesses:   
        # print then out the character
            print char,   
        # if not found, print a dash
            print "_",     
        # and increase the failed counter with one
            failed += 1   
    # if failed is equal to zero
    # print You Won
    if failed == 0:       
        print '\nYou won'
    # exit the script
    # ask the user go guess a character
    guess = raw_input('guess a character:')
    # set the players guess to guesses
    guesses += guess                   
    # if the guess is not found in the secret word
    if guess not in word: 
     # turns counter decreases with 1 (now 9)
        turns -= 1       
    # print wrong
        print 'Wrong\n'   
    # how many turns are left
        print 'You have', + turns, 'more guesses'
    # if the turns are equal to zero
        if turns == 0:           
        # print "You Loose"
            print 'You Loose\n'
Last edited by micseydel on Sun Jan 12, 2014 11:20 am, edited 1 time in total.
Reason: Locked OP, code tags.
Posts: 1
Joined: Sun Jan 12, 2014 9:33 am

Re: Python coding problems need HELP!

Postby Yoriz » Sun Jan 12, 2014 11:29 am

Hi welcome to the forum.
Please read the 'new users, read this' link in my signature.

There is no traceback of any error your getting or no description of what it is not doing for you that it should be.
Due to the reasons discussed here we will be moving to on October 1 2016
This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.
User avatar
Posts: 1672
Joined: Fri Feb 08, 2013 1:35 am
Location: UK

Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 8 guests