Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'string.': 0.05; 'finished,': 0.07; 'string': 0.09; 'correct,': 0.09; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; 'wrote': 0.14; '"enter': 0.16; 'acted': 0.16; 'outputs': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'input': 0.22; 'coding': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'error': 0.23; 'subject: .': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'testing': 0.29; 'correct': 0.29; 'chris': 0.29; 'dec': 0.30; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'code': 0.31; 'url:python': 0.33; 'are:': 0.33; 'subject:the': 0.34; 'skip:- 50': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; '14,': 0.36; 'otherwise.': 0.36; 'url:listinfo': 0.36; 'url:org': 0.36; 'pm,': 0.38; 'url:mail': 0.40; 'matter': 0.61; 'taking': 0.65; 'to:addr:gmail.com': 0.65; 'here': 0.66; 'revealed': 0.68; 'saving': 0.69; 'here!': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=4MdObjGeJcISQHc5yH6znqUDmGUSkkPpP4vMe4WTr3g=; b=pPmg2Ra+W4letXKerqQTezB3g6QaVPkeqpWJGifPOhBdNSCGwFoNICSblhYS/2XqNG xgesObhQpW2G6LIGkWjpHaG4aOtvACvw+cJ4B3AtadMBaedE9lBa+cO3uamnBz9dCEWd Mw866jNG+9JZDaRVrDvnFsratLp/cu4LwGnl2dmAPm7mVv2tGXE6baKStXSAENjT+jll cZwvzSUfugJ1fwwh9ZZ5hCRvDc1KJMUZZHiKXwDiicyaTsjX8va+gz1hG6E3HP63Z+7Q qsncUJ/BhQAIkGYo8y3AfoNMPkyjPXlsRDFql9xtEdoNkoSNw2InUljaN9bymvEaGg6i 1vsg== MIME-Version: 1.0 X-Received: by 10.112.8.69 with SMTP id p5mr26036632lba.97.1418578013520; Sun, 14 Dec 2014 09:26:53 -0800 (PST) In-Reply-To: <3abc022a-2916-4bfb-b722-20037a646045@googlegroups.com> References: <3abc022a-2916-4bfb-b722-20037a646045@googlegroups.com> Date: Sun, 14 Dec 2014 18:26:53 +0100 Subject: Re: How to use the .isalpha() function correctly From: Chris Warrick To: Luke Tomaneng Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org 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: 1418578022 news.xs4all.nl 2967 [2001:888:2000:d::a6]:38537 X-Complaints-To: abuse@xs4all.nl Path: csiph.com!usenet.pasdenom.info!bete-des-vosges.org!feed.ac-versailles.fr!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Xref: csiph.com comp.lang.python:82518 On Sun, Dec 14, 2014 at 6:16 PM, Luke Tomaneng wro= te: > Here a very small program that I wrote for Codecademy. When I finished, C= odecademy acted like it was correct, but testing of this code revealed othe= rwise. > -------------------------------------------------- > print 'Welcome to the Pig Latin Translator!' > > # Start coding here! > raw_input("Enter a word:") > original =3D str(raw_input) > if len(original) > 0 and original.isalpha(): > print original > else: > print "empty" > -------------------------------------------------- > No matter what I type in, the result is "empty." What do I need to do in = order for it to accept words? > -- > https://mail.python.org/mailman/listinfo/python-list That=E2=80=99s not where the error is, actually. You are: 1. taking input with "Enter a word: " and NOT SAVING IT 2. setting original to a string representation of the function `raw_input`, which is something like >>> str(raw_input) '' The correct way to do this is: original =3D raw_input("Enter a word: ") as raw_input already outputs a string. --=20 Chris Warrick PGP: 5EAAEA16