Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #40591

Re: Input wont work with if statement if it has a space

X-Received by 10.224.19.78 with SMTP id z14mr22772680qaa.4.1362534633027; Tue, 05 Mar 2013 17:50:33 -0800 (PST)
X-Received by 10.49.49.193 with SMTP id w1mr1706644qen.3.1362534632915; Tue, 05 Mar 2013 17:50:32 -0800 (PST)
Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!t2no9174431qal.0!news-out.google.com!p7ni1qai.0!nntp.google.com!dd2no7344862qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.python
Date Tue, 5 Mar 2013 17:50:32 -0800 (PST)
In-Reply-To <mailman.2916.1362527253.2939.python-list@python.org>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=75.62.131.238; posting-account=T0Q4ngoAAADFqe_JPINLNp5NgW2XDzan
NNTP-Posting-Host 75.62.131.238
References <f19881f0-8f12-42eb-a55a-49b858c9b50f@googlegroups.com> <dbf70d62-0425-43c2-ab11-37dfdcccb458@googlegroups.com> <mailman.2916.1362527253.2939.python-list@python.org>
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <71e39dc3-1b79-4331-9d4f-eb94c64068ce@googlegroups.com> (permalink)
Subject Re: Input wont work with if statement if it has a space
From eli m <techgeek201@gmail.com>
Cc python-list@python.org
Injection-Date Wed, 06 Mar 2013 01:50:32 +0000
Content-Type text/plain; charset=ISO-8859-1
Xref csiph.com comp.lang.python:40591

Show key headers only | View raw


On Tuesday, March 5, 2013 3:47:31 PM UTC-8, emile wrote:
> On 03/05/2013 03:33 PM, eli m wrote:
> 
> > On Tuesday, March 5, 2013 3:31:13 PM UTC-8, eli m wrote:
> 
> >> Hi guys, i have a program like this: (A lot of code is not included)
> 
> >>
> 
> >> run = 0
> 
> >>
> 
> >> while run == 0:
> 
> >>
> 
> >>     function = raw_input("Type in a function:")
> 
> >>
> 
> >>     if function == "Example":
> 
> 
> 
> whenever function isn't _exactly_ "Example" the else clause executes.
> 
> 
> 
> If you want to catch forms of example you might try:
> 
> 
> 
>      if function.strip().upper() == "EXAMPLE":
> 
> 
> 
> Emile
> 
> 
> 
> 
> 
> 
> 
> 
> 
> >>
> 
> >>        print ("Hello World!")
> 
> >>
> 
> >>     else:
> 
> >>
> 
> >>        print ("blah blah blah")
> 
> >>
> 
> >>
> 
> >>
> 
> >> The problem is that whenever i type in example with a space after it then it prints the else statement.
> 
> >>
> 
> >>
> 
> >>
> 
> >> My question is, how do i get it to except input with spaces?
> 
> >
> 
> > oops i meant function = raw_input("Type in a function:")
> 
> >

Thank you!

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Input wont work with if statement if it has a space eli m <techgeek201@gmail.com> - 2013-03-05 15:31 -0800
  Re: Input wont work with if statement if it has a space eli m <techgeek201@gmail.com> - 2013-03-05 15:33 -0800
    Re: Input wont work with if statement if it has a space emile <emile@fenx.com> - 2013-03-05 15:47 -0800
      Re: Input wont work with if statement if it has a space eli m <techgeek201@gmail.com> - 2013-03-05 17:50 -0800
      Re: Input wont work with if statement if it has a space eli m <techgeek201@gmail.com> - 2013-03-05 17:50 -0800

csiph-web