Some python newb help please?
Tim Chase
python.list at tim.thechases.com
Tue Nov 12 17:59:24 EST 2013
On 2013-11-12 14:27, lrwarren94 at gmail.com wrote:
> 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're asking for input with each comparison. Best to get
the input once and store it in a variable before the "if" statement
and then do the comparisons against the same value.
-tkc
More information about the Python-list
mailing list