[Tutor] Rock, Paper, Scissors
Luke Paireepinart
rabidpoobear at gmail.com
Fri Aug 11 18:53:12 CEST 2006
Robert Wierschke wrote:
> the else part can't have a condition!!!
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
Are you referring to Alan's post?
You should have included the original text in your reply so we would
know what you're talking about.
If you _are_ talking about Alan's example:
#---
outcome = results[computer.choice][human.choice]
if outcome == 0: print "Computer Wins"
elif outcome == 1: print "Human wins"
else: print 'Draw!'
#---
his else doesn't have a condition.
it's just that he only needed to do one thing in the else clause
and it looks neater to put it on one line.
else: print 'Draw!'
is equivalent to
else:
print 'Draw!'
More information about the Tutor
mailing list