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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:53:26+00:00 2026-06-04T00:53:26+00:00

I have the following code condition if len(content_tags) >= 1 or tags_irrelevant == ‘yes’\

  • 0

I have the following code condition

 if len(content_tags) >= 1 or tags_irrelevant == 'yes'\
   and lengthproblem == 0\
   and guess_language.guessLanguage(testlanguage) == 'en'\
   and len(sentences) >= 3:

The problem is about the logic and the syntax. I want this to be evaluated as false no matter if if len(sentences) is not >= 3. But this is not happening. I think I might need some parenthesis somewhere or something. HELP!

  • 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-04T00:53:29+00:00Added an answer on June 4, 2026 at 12:53 am

    and has a higher precidence than or, so the ands are evaluated first, then the or, meaning that the logic you have described in text is not the logic you have described in code.

    If you want the first or to be treated as a single case, then use brackets around it.

    if (len(content_tags) >= 1 or tags_irrelevant == 'yes')\
       and lengthproblem == 0\
       and guess_language.guessLanguage(testlanguage) == 'en'\
       and len(sentences) >= 3:
    

    That said, you haven’t given us a detailed explanation of the logical behaviour you want from this, so I’d suggest sitting down and working that out properly.

    If you need to test your logic, then use a simple test function that prints out so you know what gets evaluated and when.

    >>> def test(bool):
    ...    print(bool)
    ...    return bool
    ... 
    >>> if test(1) or test(2) and test(3) and test(4) and test(False):
    ...    print("Success")
    ... 
    1
    Success
    >>> if (test(1) or test(2)) and test(3) and test(4) and test(False):
    ...     print("Success")
    ... 
    1
    3
    4
    False
    

    You can clearly see the first thing evaluated is the first and, then it tries to evaluate the left hand side of the and and so gets the or. It tries to evaluate this, gets True for the first value, and so short-circuits, returning True to the and, which also short circuits, returning True (well, actually 1, but True for the purposes of this example). When the brackets are there, it is evaluated in the way you wanted.

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

Sidebar

Related Questions

I have the following situation: if (condition) { std::unique_ptr<AClass> a(new AClass); // code that
i have following pseudo code : void siftup(int n) pre condition n>0 && heap(1,n-1)
I have the following JavaScript code: $('a.button').click(function(){ if (condition == 'true'){ function1(someVariable); function2(someOtherVariable); }
I have the following code: <Feature Id='SMSGatewayFeatures' Title='SMS Gateway Product Feature' Level='2'> <Condition Level='1'>INSTALLSMSGATEWAYSERVICE</Condition>
I have the following code that simply loops looking for a condition and places
I have seen the following code: #define QL_REQUIRE(condition,message) \ if (!(condition)) { \ std::ostringstream
I have got the following IF condition code: if ((depth <= min_depth ) &&
I have the following code: $project.PropertyGroup | Foreach-Object { if($_.GetAttribute('Condition').Trim() -eq $propertyGroupConditionName.Trim()) { $a
I have following code.. $query = SELECT quote, author FROM quotes ORDER BY id
I have following code: <?php $select_options = array(); foreach($delivery_options as $option) { $select_options[$option->getDeviceId()] =

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.