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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:42:04+00:00 2026-05-14T04:42:04+00:00

My question is, why are these expressions False? Python 2.6.4 (r264:75706, Dec 7 2009,

  • 0

My question is, why are these expressions False?

Python 2.6.4 (r264:75706, Dec  7 2009, 18:45:15) 
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>> num = raw_input("Choose a number: ")
Choose a number: 5
>>> print num
5
>>> print ( num < 18 )
False
>>> print ( num == 5 )
False

Because if i try this:

>>> print ( num > 0 )
True

The expression works fine.

  • 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-14T04:42:04+00:00Added an answer on May 14, 2026 at 4:42 am

    This statement:

    num = raw_input("Choose a number: ")
    

    makes num a string, not a number, despite its misleading name. It so happens that Python 2 lets you compare strings with numbers, and in your version considers all strings larger than all numbers (the contents of the string play no role).

    Use num = int(num) to make an integer (and be sure to use a try/except to catch possible errors when the user has typed something other than a number!) before you start comparing.

    (In Python 3, the function’s name changes from raw_input to input, and it still returns strings; however in Python 3 comparing a string with a number is considered an error, so you would get an exception rather than True or False in each of your comparison attempts).

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

Sidebar

Ask A Question

Stats

  • Questions 344k
  • Answers 344k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use the /codebase switch when running regasm. May 14, 2026 at 5:41 am
  • Editorial Team
    Editorial Team added an answer Ok i found a solution, though i find it a… May 14, 2026 at 5:41 am
  • Editorial Team
    Editorial Team added an answer Depending on the size of the job the thread has… May 14, 2026 at 5:41 am

Related Questions

I am writing an application using the MVVM pattern. I am providing data to
DBML I have the following entities in my dbml: (made up for an example)
I am testing a static method that builds a URL string after checking proxies
A recent homework assignment I have received asks us to take expressions which could
I Just can't seem to wrap my head around them. As I understand it's

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.