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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:23:25+00:00 2026-05-26T11:23:25+00:00

imagine I type the following code into the interpreter: var1 = ‘zuuzuu’ now suppose

  • 0

imagine I type the following code into the interpreter:

var1 = 'zuuzuu'

now suppose i type:

var1.find('a')

the interpreter returns -1. which i understand because the substring has not been found. but please help me understand this:

var1.find('a' or 'z') #case 1

returns -1

but

var1.find('a' and 'z') #case 2

returns 0

According to the logic in my head the interpreter should return -1 for case 2 because the substrings ‘a’ AND ‘z’ are NOT located in the string. While in case 1, 0 should be returned since ‘z’ is a substring.

thanks

  • 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-26T11:23:25+00:00Added an answer on May 26, 2026 at 11:23 am

    Expression 'a' or 'z' always yields 'a'. Expression 'a' and 'z' always yields 'z'. It’s not some kind of DSL for making queries into containers, it’s a simple boolean expression (and find is called with its result). If you want to say “is there ‘a’ or ‘z’ in the string”, you need to do

    var1.find('a') != -1 or var.find('z') != -1
    

    And for the second one (both ‘a’ and ‘z’ in the string):

    var1.find('a') != -1 and var.find('z') != -1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Imagine I have the following code: class A { [UsefulAttribute(foo)] B var1; [UsefulAttribute(bar)] B
Imagine the following A type T has a field Company. When executing the following
Imagine the following simple code: public void F<T>(IList<T> values) where T : struct {
Imagine the following code, written in C#: public class Provider<T> { T GetValue(); //
Imagine the following code: class foreach_convert { public static void method2() { List<IComparable> x
I have the following piece of code, which prints the metadata of an image
I have an autocomplete text box that users can type an item code into
Imagine the typical type of application where you have a list of items with
Imagine I have a recursive algebraic data type like this (Haskell syntax): data Expr
Imagine an interface with a method to create objects of type Address . The

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.