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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:38:45+00:00 2026-05-30T06:38:45+00:00

Consider the statement below: Prob 1: >>> a=abc >>> ‘d’ or ‘e’ in a

  • 0

Consider the statement below:

Prob 1:

>>> a="abc"
>>> 'd' or 'e' in a
'd'

Someone please explain this . I was expecting a True or False …

Prob 2:

>>> print any(c in a for c in 'da')
True

Whats happening here ? If i do this ,

>>> (c in a for c in 'da')
<generator object <genexpr> at 0x011E4300>

As you can see , it gives generator object…What role does ‘any’ (method,function ??) play
here? And the result ?

Prob 3:

>>> Pattern="sdfdfg"
>>> if '\\'or '^' or '.' in Pattern:
    print "yes"
else:print "no"

yes

How on earth is this “YES” ??

Show me the light someone plz………..

  • 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-30T06:38:46+00:00Added an answer on May 30, 2026 at 6:38 am

    The results you are seeing are the result of the precedence of the or and in operators being different than you expect.

    • 'd' or 'e' in a

    This should be read as 'd' or ('e' in a), that is, the 2 operands to or are 'd' and ('e' in a). Since d is considered a true value in python, or doesn’t look at its next operand, and just returns its first operand, 'd'. Note that this means that or isn’t just a logical OR, it can deal with other types, and return other types.

    • print any(c in a for c in 'da')

    Read this print any((c in a) for c in 'da'), ie, go over the elementns of 'da', test if that letter is also in a, and then see if that held true for any of them. The reason you see <generator object <genexpr> at 0x011E4300> is that Python does not show you the elements of a generator unless it has cause to step over them. If you want to see the individual elements, write:

    [(c in a) for c in 'da']
    
    • if '\\'or '^' or '.' in Pattern:

    Again, read this if ('\\' or '^') or ('.' in Pattern:). Since '\\' is true, the result is true.

    Table of precedence

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

Sidebar

Related Questions

Please consider this sql statements Create table abc (A int, B int ) insert
Consider the DUPoint class, whose declaration appears below. Assume this code appears in a
Some may or may not consider this a complex statement, but for me (since
Consider this statement: INSERT INTO table (a,b,c) VALUES (1,2,3) ON DUPLICATE KEY UPDATE d=d+1;
Consider this simple table : table create statement is : CREATE TABLE [dbo].[Test_Serializable]( [Id]
Consider the following code snippet: #!/bin/bash #This program tests the if statement in bash.
Below is the statement written from Wikipedia's Isolation article about REPEATABLE READS In this
consider the following pgSQL statement: SELECT DISTINCT some_field FROM some_table WHERE some_field LIKE 'text%'
Is it safe to use the using statement on a (potentially) null object? Consider
Consider this problem: I have a program which should fetch (let's say) 100 records

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.