Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'definitions': 0.07; 'escape': 0.09; 'ex:': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'runs': 0.10; 'subject:Help': 0.11; 'python': 0.11; 'boolean': 0.16; 'dictionary,': 0.16; 'quit.': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'subroutine': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'trying': 0.19; 'header:User- Agent:1': 0.23; 'adds': 0.24; 'options': 0.25; 'header:X -Complaints-To:1': 0.27; 'words': 0.29; "i'm": 0.30; 'work.': 0.31; 'asked': 0.31; 'context,': 0.31; 'once,': 0.31; 'run': 0.32; 'but': 0.35; 'add': 0.35; 'entry': 0.36; 'possible': 0.36; 'to:addr:python-list': 0.38; 'list,': 0.38; 'anything': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'expression': 0.60; 'break': 0.61; 'new': 0.61; 'simple': 0.61; 'forward': 0.65; 'entry,': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Peter Otten <__peter__@web.de> Subject: Re: Help Date: Fri, 26 Jul 2013 07:27:55 +0200 Organization: None References: <067018ce-ca0c-415b-a5d3-3c2f79f11e8e@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Gmane-NNTP-Posting-Host: p5084a063.dip0.t-ipconnect.de User-Agent: KNode/4.7.3 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1374816489 news.xs4all.nl 15980 [2001:888:2000:d::a6]:38691 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51283 tyler@familyrobbins.com wrote: > I'm a bit new to python and I'm trying to create a simple program which > adds words and definitions to a list, and then calls them forward when > asked to. > while escape < 1: > > choice = input("Type 'Entry' to add a word to the Dictionary, 'Search' > to find a word, and 'Exit' to quit. ") > > if choice == '`': > break > > if choice == 'Entry' or 'entry': > However, if I run the program using anything but 'entry', the program > still runs the 'entry' subroutine. After the 'entry' subroutine is run > once, no options work. Ex: The expression choice == 'Entry' or 'entry' is evaluated by Python as (choice == 'Entry') or 'entry' All strings but "" are True in a boolean context, so this has the same effect as (choice == 'Entry') or True and is always True. Possible fixes: if choice == "Entry" or choice == "entry": if choice in ("Entry", "entry"): if choice.casefold() == "entry".casefold(): # will accept ENTRY, eNtRy etc.