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, lrwarre...@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

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to