Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #92491
| References | <3bf5dd52-c698-4392-be2b-5c0aeefc3cd3@googlegroups.com> <mailman.402.1434037847.13271.python-list@python.org> <6a171772-23a5-471d-a4e5-73f195c9055c@googlegroups.com> |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | 2015-06-11 10:47 -0600 |
| Subject | Re: Error in or |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.403.1434041298.13271.python-list@python.org> (permalink) |
On Thu, Jun 11, 2015 at 10:39 AM, <subhabrata.banerji@gmail.com> wrote:
> On Thursday, June 11, 2015 at 9:20:59 PM UTC+5:30, Ian wrote:
>> On Thu, Jun 11, 2015 at 9:40 AM,
>> > if write this it is working fine, but if I write
>> >
>> > if ("AND" in inp1) or ("OR" in inp1) or ("NOT" in inp1) or (">" in inp1) or ("&" in inp1) or ("MAYBE" in inp1) or ("(" in inp1) or ("*" in inp1) or (''' " ''' in inp1):
>> >
>> > the portion of (''' " ''' in inp1) is not working.
>>
>> Not working how? I copy-pasted the line and it appears to work fine.
>
> Dear Sir,
> Thank you for your kind reply. Nice to know your reply, but I am trying to send you my experiment, please see my results,
>
>>>> def input1(n):
> inp1=raw_input("PRINT YOUR QUERY:")
> if ("AND" in inp1) or ("OR" in inp1) or ("NOT" in inp1) or (">" in inp1) or ("&" in inp1) or ("MAYBE" in inp1) or ("(" in inp1) or ("*" in inp1) or (''' " ''' in inp1):
> print "FINE"
>
>
>>>> input1(1)
> PRINT YOUR QUERY:"Java"
>>>> input1(1)
> PRINT YOUR QUERY:"Obama in London"
>>>> input1(1)
> PRINT YOUR QUERY:Obama AND Bush
> FINE
>>>> input1(1)
> PRINT YOUR QUERY:Obama OR Bush
> FINE
>>>>
>
> you may get better my problem.
The substring that you're looking for has spaces around the " symbol.
The example inputs that you gave don't have spaces around the "
symbols, so they don't contain the substring. The triple quotes are
also unnecessary, though harmless -- it's not a multiline string, and
there are no ' symbols to escape in the string. Try replacing the
substring with just this: '"'.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Error in or subhabrata.banerji@gmail.com - 2015-06-11 08:40 -0700
Re: Error in or Ian Kelly <ian.g.kelly@gmail.com> - 2015-06-11 09:49 -0600
Re: Error in or subhabrata.banerji@gmail.com - 2015-06-11 09:39 -0700
Re: Error in or Ian Kelly <ian.g.kelly@gmail.com> - 2015-06-11 10:47 -0600
Re: Error in or subhabrata.banerji@gmail.com - 2015-06-11 10:21 -0700
Re: Error in or Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-06-11 18:54 +0100
Re: Error in or Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-06-12 09:41 +0000
Re: Error in or Marko Rauhamaa <marko@pacujo.net> - 2015-06-12 12:55 +0300
csiph-web