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


Groups > comp.lang.python > #40583

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

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'clause': 0.07; 'try:': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'guys,': 0.16; 'included)': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'statement.': 0.16; 'world!")': 0.16; 'wrote:': 0.17; 'input': 0.18; 'meant': 0.21; 'example': 0.23; 'this:': 0.23; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'question': 0.27; 'header:X-Complaints-To:1': 0.28; 'run': 0.28; 'prints': 0.29; 'function': 0.30; 'code': 0.31; 'print': 0.32; 'problem': 0.33; 'to:addr:python-list': 0.33; 'pm,': 0.35; 'received:org': 0.36; 'except': 0.36; 'subject:with': 0.36; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'space': 0.39; 'header:Received:5': 0.40; '2013': 0.84; 'received:pacbell.net': 0.84; 'subject:space': 0.84; 'eli': 0.93
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From emile <emile@fenx.com>
Subject Re: Input wont work with if statement if it has a space
Date Tue, 05 Mar 2013 15:47:31 -0800
References <f19881f0-8f12-42eb-a55a-49b858c9b50f@googlegroups.com> <dbf70d62-0425-43c2-ab11-37dfdcccb458@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host adsl-69-226-129-65.dsl.pltn13.pacbell.net
User-Agent Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130106 Thunderbird/17.0.2
In-Reply-To <dbf70d62-0425-43c2-ab11-37dfdcccb458@googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2916.1362527253.2939.python-list@python.org> (permalink)
Lines 42
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1362527253 news.xs4all.nl 6870 [2001:888:2000:d::a6]:53532
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:40583

Show key headers only | View raw


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:")
>

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