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


Groups > comp.lang.python > #52234

Re: Issues with if and elif statements in 3.3

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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; 'elif': 0.05; 'granted,': 0.07; 'none:': 0.07; '"if': 0.09; '"no"': 0.09; 'args)': 0.09; 'parsing': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; '"elif"': 0.16; '"if"': 0.16; 'message- id:@4ax.com': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:3.3': 0.16; 'thu,': 0.19; 'command': 0.22; 'input': 0.22; '+0000': 0.22; 'aug': 0.22; 'print': 0.22; '"you': 0.24; 'url:home': 0.24; 'regardless': 0.24; 'header:X-Complaints-To:1': 0.27; 'supposed': 0.32; 'subject:with': 0.35; 'something': 0.35; 'there': 0.35; 'charset :us-ascii': 0.36; 'should': 0.36; 'ends': 0.38; 'to:addr:python- list': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'enough': 0.39; 'received:org': 0.40; 'dave': 0.60; 'skip:a 30': 0.61; 'happen': 0.63; 'stand': 0.64; 'provide': 0.64; 'chance': 0.65; 'determine': 0.67; 'angel': 0.91; 'lift': 0.91; 'received:108': 0.93; '2013': 0.98
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Issues with if and elif statements in 3.3
Date Thu, 08 Aug 2013 19:31:55 -0400
Organization IISS Elusive Unicorn
References <02128546-7a5d-4fe8-a472-47cfd4f76342@googlegroups.com> <ktvs8f$ei2$1@ger.gmane.org>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host adsl-108-79-216-177.dsl.klmzmi.sbcglobal.net
X-Newsreader Forte Agent 6.00/32.1186
X-No-Archive YES
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.378.1376004726.1251.python-list@python.org> (permalink)
Lines 66
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1376004726 news.xs4all.nl 15868 [2001:888:2000:d::a6]:41974
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:52234

Show key headers only | View raw


On Thu, 8 Aug 2013 10:34:57 +0000 (UTC), Dave Angel <davea@davea.name>
declaimed the following:

>
>Or less typing:
>
>if answer in ("yes", "Yes", "y"):
>

	Or (IF there is no chance for ambiguity)

	if answer.lower().startswith("y"):

	If there is ambiguity, provide enough of the matchword to determine the
unique option...

	if answer.lower().startswith("ye"):
		do_Yell_Action(rest_of_input_line)
	elif answer.lower().startswith("yi"):
		do_Yield_Action(rest_of_input_line)

	Granted, if parsing command options, you might want to lift the
.lower() out of the "if" conditions

	answer = answer.lower()
	if answer.startswith(...

{to expand (2.x syntax)}

	command = raw_input("Enter command> ")
	command = command.lower().split()

	(answer, args) = (command[0], command[1:])

	operation = None
	if answer.startswith("ye"):
		operation = do_Yell_Action
	elif answer.startswith("yi"):
		operation = do_Yield_Action
	elif answer.startswith("dr"):
		operation = do_Drop_Action
...

	if operation is not None:
		operation(args)
	else:
		print "That is not a valid command"


>
>
>
>>         print("You set out for the Coffeington Caves")
>>     elif answer == ("no") or ("No") or ("n"):
>>         print("Oh...well im sure you can find something else to do")
>>     else:
>>         print("You just stand  there")
>> town()
>>
>>
>>
>> i don't know why the "elif" or "else" part of the "if statment" wont trigger. what ends up happening is that regardless of what answer you put in input it will always print out "you set out for the Coffeington Caves". whats supposed to happen is if you say "no" it should just end? i think anway.
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

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


Thread

Issues with if and elif statements in 3.3 krismesenbrink@gmail.com - 2013-08-08 00:19 -0700
  Re: Issues with if and elif statements in 3.3 Dave Angel <davea@davea.name> - 2013-08-08 10:34 +0000
    Re: Issues with if and elif statements in 3.3 Kris Mesenbrink <krismesenbrink@gmail.com> - 2013-08-08 15:20 -0700
      Re: Issues with if and elif statements in 3.3 Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-08-08 19:37 -0400
  Re: Issues with if and elif statements in 3.3 Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-08-08 19:31 -0400

csiph-web