[Tutor] Rock, Paper, Scissors

Robert Wierschke wierob at gmx.de
Sat Aug 12 12:06:56 CEST 2006


sorry I answerd to

Message: 2
Date: Thu, 10 Aug 2006 16:39:41 -0700 (PDT)
From: Christopher Spears <cspears2002 at yahoo.com>
Subject: [Tutor] Rock, Paper, Scissors


and his else has a condition

>    else human.choice == 'scissors' and computer.choice
>== 'rocks':
>        print "Computer wins!"
>        computer.points = computer.points + 1



Luke Paireepinart schrieb:
> 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