Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!newsreader4.netcologne.de!news.netcologne.de!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'elif': 0.05; 'odd': 0.07; 'preference': 0.07; 'subject:help': 0.08; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'west,': 0.09; 'itself.': 0.14; 'posted': 0.15; '")"': 0.16; '"enter': 0.16; 'adjacent': 0.16; 'concatenate': 0.16; 'east,': 0.16; 'hint:': 0.16; 'message-id:@4ax.com': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:python': 0.16; "python's": 0.19; 'command': 0.22; 'code,': 0.22; 'input': 0.22; 'print': 0.22; '"you': 0.24; 'url:home': 0.24; 'question': 0.24; 'compare': 0.26; 'skip:" 30': 0.26; 'post': 0.26; 'header:X -Complaints-To:1': 0.27; 'leave': 0.29; "doesn't": 0.30; 'locations': 0.30; 'subject:please': 0.30; 'code': 0.31; 'page.': 0.31; 'that.': 0.31; 'int,': 0.31; 'though.': 0.31; 'quite': 0.32; 'link.': 0.33; 'display': 0.35; 'charset:us-ascii': 0.36; "i'll": 0.36; 'subject:?': 0.36; 'half': 0.37; 'received:76': 0.38; 'nov': 0.38; 'to:addr:python-list': 0.38; 'ability': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'read': 0.60; 'new': 0.61; 'took': 0.61; 'email addr:gmail.com': 0.63; 'provide': 0.64; 'road': 0.65; 'world': 0.66; 'here': 0.66; 'prompt': 0.68; 'user,': 0.69; 'lack': 0.78; 'fare': 0.84; 'north,': 0.91; '2013': 0.98 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Some python newb help please? Date: Tue, 12 Nov 2013 20:49:34 -0500 Organization: IISS Elusive Unicorn References: <22894a10-1ffd-4671-94f4-962dfb56e4fd@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-76-249-20-110.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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 62 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1384307390 news.xs4all.nl 15923 [2001:888:2000:d::a6]:43148 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:59276 On Tue, 12 Nov 2013 14:27:37 -0800 (PST), lrwarren94@gmail.com declaimed the following: > >I'm not quite sure what you mean by that. it was on that pastebin link. I'll post it again here though. it's no longer than half a page. The preference here is that if you ask a question about code, you provide the code IN the message -- you don't send us off to some site that may or may not retain the code down the road (whereas the question posted here may be archived forever) > >x = 0 >y = 0 >quitCommand = 0 > >print "Welcome to the World of Textcraft!" >print "----------------------------------" >print "" > >while quitCommand != int(5): 5 IS an int, so why coerce it to itself. > print "You are currently at (" + str(x) + ", " + str(y) + ")" > print "Enter a command (1 = North, 2 = East, 3 = South, 4 = West, 5 = Exit):" > if int(raw_input()) == 1: > print "Moving north" > y = y + 1 > elif int(raw_input()) == 2: > print "Moving east" > x = x + 1 > elif int(raw_input()) == 3: > print "Moving south" > y = y - 1 > elif int(raw_input()) == 4: > print "Moving west" > x = x - 1 > elif int(raw_input()) == 5: > print "Dost thou leave so soon? Fare thee well!" > quitCommand = 5 > else: > print "I find your lack of reading comprehension skills disturbing." > Note that you ask for NEW input from the user on each if/elif. You want to read ONE value from the user, and then compare THAT value on each if/elif line. HINT: raw_input() can display a prompt string... so command = int(raw_input( "Enter a command " "(1 = North, 2 = East, 3 = South, 4 = West, 5 = Exit): ")) {Note: I took advantage of Python's ability to concatenate adjacent strings -- that way the line doesn't wrap at odd locations in UseNet} -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/