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 6168403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:40:55+00:00 2026-05-23T22:40:55+00:00

Possible Duplicate: Learning Python: If condition executing all the time This Python code is

  • 0

Possible Duplicate:
Learning Python: If condition executing all the time

This Python code is for guessing a number from 1 to 100. There is nothing wrong with the ‘guesser()’ function, which I know because my program also has a “manual mode” that works perfectly. For some reason, it always assigns the ‘guesss’ value to ‘low’ and keeps doing so until it equals 100 and the program “Ragequits”. It never does anything to ‘high’, which stays at its default throughout the execution. No matter what, it never executes the “winning” block.
NOTE: The variables ‘high’ and ‘low’ start as 101 and 0 respectively, and ‘guesser()’ chooses a number between them. ‘goOn’ is used earlier in the code to determine if the person wants to play again.

            num = raw_input('Enter the number which you want the computer to guess. ')
            unguessed = True
            while unguessed:
                if high == low + 1 or high <= low:
                    print 'Waitafligginflagginminnit! You CHEATED! *Ragequits*'
                    goOn = False
                    unguessed = False
                    print ''
                    raw_input('Press Enter to continue.')
                guesses = guesses + 1
                guesss = guesser()
                print 'I guessed', guesss
                if guesss == num:
                    print 'Yay! I won in', guesses, 'guesses!'
                    again = raw_input('Just press enter if you want to play again. Otherwise...you know the drill. ')
                    unguessed = False
                    print '\n\n'
                    if again:
                        goOn = False
                else:
                    print 'Awww...'
                    if guesss > num:
                        high = guesss
                    elif guesss < num:
                        low = guesss
  • 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-05-23T22:40:55+00:00Added an answer on May 23, 2026 at 10:40 pm

    You should use int(raw_input()) instead of raw_input in order to retain the guess as an integer. raw_input() alone returns a string, and so comparisons will not hold.

    See these previously answered question, and this exact question as yours.

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

Sidebar

Related Questions

Possible Duplicate: What does ‘unsigned temp:3’ means I'm learning some kernel code, and came
Possible Duplicate: Is there a printf converter to print in binary format? Still learning
Possible Duplicate: How to stop C++ console application from exiting immediately? So im learning
Possible Duplicate: Is there a printf converter to print in binary format? Consider this
Possible Duplicate: Difference between Convert.tostring() and .tostring() Hi Carrying on from this question What
Possible Duplicate: MVVM: Tutorial from start to finish? i just started learning WPF. i
Possible Duplicate: Generating random integer from a range I just started learning C++ and
Possible Duplicate: Learning C++: polymorphism and slicing This is building off a question I
Possible Duplicate: Wrapper class and == operator Saw this code in a website when
Possible Duplicate: How do I calculate someone's age in C#? Maybe this could be

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.