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

  • SEARCH
  • Home
  • 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 6141433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:15:00+00:00 2026-05-23T18:15:00+00:00

I am learning python and i can’t figure out why the following program is

  • 0

I am learning python and i can’t figure out why the following program is printing your number is greater than what i thought even when the guessed number is smaller. is it like in python, it is comparing strings rather the numbers ?

number = 32
tries = 1

print "I have chosen a number, you have to guess it."
guess = raw_input ("Guess:")

while guess != number:
    tries = tries+1
    if guess > number:
        print("Your guess is greater than i thought")
        guess = raw_input ("Another Guess:")
    else:
        print("Your guess is smaller than i thought")
        guess = raw_input ("Another Guess:")

print "You guess it right in %d turns." %tries

P.S:I know its a dumb question but i am a noob at python!

  • 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-23T18:15:01+00:00Added an answer on May 23, 2026 at 6:15 pm

    I didn’t know this until just now, but as it turns out, a string will always be “greater than” an integer in Python:

    >>> "0" > 1
    True
    

    All you need to do is replace

    guess = raw_input ("Guess:")
    

    with

    guess = int(raw_input ("Guess:"))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am learning python and have this error . I can figure out where\what
I am learning Python and trying to figure out an efficient way to tokenize
I'm learning Python with the tutorial app from Flask and I can't figure how
I'm learning Python and can't even write the first example: print 2 ** 100
I've been learning python for a while now with some success. I even managed
I'm really interested in learning Python for web development. Can anyone point me in
I am learning Python and so far I can tell the things below about
I have been learning Python by following some pygame tutorials . Therein I found
I am learning python and I am challenging myself to write a little program
I am just learning python and is interested in how this can be accomplished.

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.