Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8801113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:45:13+00:00 2026-06-14T00:45:13+00:00

I am writing a hangman game program in python and have run into a

  • 0

I am writing a hangman game program in python and have run into a problem concerning validating loops. Here is an example of the type of problem:

    def loopGet():
        condition = True
        while condition == True:
            userInput = raw_input("Enter a string: ")
            # assigns boolean value to condition
            condition = ifWon()
            # returns condition
            return condition
            #assigns boolean value
            condition = ifLost()
            #return condition
            return condition

Pretending that ifWon() and ifLost() are already created, this is an example of what’s going and what I am trying to figure out. In my program, even if both return True, the loop ends. If one returns True and the other False, it still ends. I am under the impression that if “condition” returns True, the loop should keep running; yes?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T00:45:14+00:00Added an answer on June 14, 2026 at 12:45 am

    The loop “ends” because the method’s execution stops at the return statement. Since your return statement is inside your while loop, it appears that you condition is not working.

    Once you move the return statement outside your loop, you’ll get your expected results.


    def game():
    
        isWinner = False
        while isWinner == False:
           # as the user for a guess
           # check the guess
           isWinner = isWon()
        return "You won!"
    

    You set a variable to the condition that you want to change. So isWinner = False, then while isWinner == False: do your loop. If isWon() returns True or False, then in your while isWinner = isWon(). You don’t need isLost(), as we want the loop to exit when the user has won.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Odd problem here. I'm writing a simple Hangman game in PHP, and while checking
Writing a hangman program in python and I've come across a problem when passing
I am writing a python hangman program, and I wanted to be able to
I'm writing a hangman game. I'm having a logic fail, both with myself and
I'm writing a console-environment Hangman game for my introductory programming class. The player chooses
Writing a test app to emulate PIO lines, I have a very simple Python/Tk
Writing a python program, and I came up with this error while using the
Writing a simple example from Odersky's book resulted in the following problem: // AbstractElement.scala
writing a basic math program to help me understand python math calculation. if I
I am writing a basic hangman game. I want to store a string Word

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.