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


Groups > comp.lang.python > #59245

Re: Some python newb help please?

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!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.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'from:addr:yahoo.co.uk': 0.04; 'elif': 0.05; 'output': 0.05; 'class,': 0.07; 'rename': 0.07; 'subject:help': 0.08; 'advice.': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'tismer': 0.09; 'west,': 0.09; 'python': 0.11; '")"': 0.16; '"enter': 0.16; 'command,': 0.16; 'comparison.': 0.16; 'east,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:python': 0.16; 'language': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'trying': 0.19; 'thanks.': 0.20; 'command': 0.22; '>>>': 0.22; 'input': 0.22; 'programming': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; '"you': 0.24; 'url:moin': 0.24; 'fine': 0.24; 'guys': 0.24; 'appreciated': 0.26; 'compare': 0.26; 'skip:" 30': 0.26; 'second': 0.26; 'post': 0.26; 'asking': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'wondering': 0.29; 'leave': 0.29; "doesn't": 0.30; 'is?': 0.30; 'statement': 0.30; 'subject:please': 0.30; "i'm": 0.30; 'code': 0.31; 'page.': 0.31; 'that.': 0.31; 'url:wiki': 0.31; 'once,': 0.31; 'quotes': 0.31; 'though.': 0.31; 'anyone': 0.31; 'figure': 0.32; 'quite': 0.32; 'url:python': 0.33; 'link.': 0.33; 'could': 0.34; 'problem': 0.35; "can't": 0.35; 'something': 0.35; 'but': 0.35; 'google': 0.35; 'idle': 0.36; "i'll": 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'half': 0.37; 'too': 0.37; 'christian': 0.38; 'to:addr:python- list': 0.38; 'does': 0.39; '12,': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'read': 0.60; 'above,': 0.60; 'world.': 0.61; "you're": 0.61; 'first': 0.61; 'email addr:gmail.com': 0.63; 'world': 0.66; 'here': 0.66; 'anything.': 0.68; 'enjoy': 0.71; 'inline': 0.74; '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 Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: Some python newb help please?
Date Tue, 12 Nov 2013 22:54:40 +0000
References <f9bcd68d-ac00-421a-ade5-5f5690861d25@googlegroups.com> <mailman.2490.1384294935.18130.python-list@python.org> <22894a10-1ffd-4671-94f4-962dfb56e4fd@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 host-92-24-215-29.ppp.as43234.net
User-Agent Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.1.0
In-Reply-To <22894a10-1ffd-4671-94f4-962dfb56e4fd@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 <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2494.1384296897.18130.python-list@python.org> (permalink)
Lines 91
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1384296897 news.xs4all.nl 16006 [2001:888:2000:d::a6]:42685
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:59245

Show key headers only | View raw


First thing would you please read and action this 
https://wiki.python.org/moin/GoogleGroupsPython so we don't have to read 
double spaced google crap, thanks.

On 12/11/2013 22:27, lrwarren94@gmail.com wrote:
> On Tuesday, November 12, 2013 4:21:58 PM UTC-6, Mark Lawrence wrote:
>> On 12/11/2013 22:14, lr....@gmail.com wrote:
>>
>>> So I'm trying to write a program for a problem in class, and something strange is happening that I can't figure out why is happening. I was wondering if you guys could help me fix it?
>>
>>>
>>
>>> http://pastebin.com/6QZTvx6Z
>>
>>>
>>
>>> Basically, 1 and 2 work just fine as inputs, but whenever I input 3 or 4, idle just doesn't do anything. Does anyone know why that is? any suggestions on how to fix? Any help is much appreciated :)
>>
>>>
>>
>>
>>
>> Please put your code inline so we can see it, if it's too long see this
>>
>> http://sscce.org/ for advice.
>>
>>
>>
>> --
>>
>> Python is the second best programming language in the world.
>>
>> But the best has yet to be invented.  Christian Tismer
>>
>>
>>
>> Mark Lawrence
>
> 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.
>
> x = 0
> y = 0
> quitCommand = 0
>
> print "Welcome to the World of Textcraft!"
> print "----------------------------------"
> print ""

You don't need the double quotes in the line above, the print statement 
on its own will output a newline.

>
> while quitCommand != int(5):
>      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."
>
>

You're asking for input in every comparison.  Change this to request the 
input once, store it and then compare it.  If you rename quitCommand to 
command, you'd have

command = int(raw_input())
if command == 1:
     etc.

Enjoy :)

-- 
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Thread

Some python newb help please? lrwarren94@gmail.com - 2013-11-12 14:14 -0800
  Re: Some python newb help please? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-12 22:21 +0000
    Re: Some python newb help please? lrwarren94@gmail.com - 2013-11-12 14:27 -0800
      Re: Some python newb help please? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-12 22:54 +0000
      Re: Some python newb help please? MRAB <python@mrabarnett.plus.com> - 2013-11-12 22:56 +0000
        Re: Some python newb help please? lrwarren94@gmail.com - 2013-11-12 15:04 -0800
          Re: Some python newb help please? Chris Angelico <rosuav@gmail.com> - 2013-11-13 10:19 +1100
      Re: Some python newb help please? Tim Chase <python.list@tim.thechases.com> - 2013-11-12 16:59 -0600
      Re: Some python newb help please? Chris Angelico <rosuav@gmail.com> - 2013-11-13 09:58 +1100
      Re: Some python newb help please? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-11-12 20:49 -0500
  Re: Some python newb help please? John Strick <jstrickler@gmail.com> - 2013-11-12 14:49 -0800
  Re: Some python newb help please? Denis McMahon <denismfmcmahon@gmail.com> - 2013-11-12 23:05 +0000

csiph-web