[Tutor] more rps
Luke Paireepinart
rabidpoobear at gmail.com
Tue Aug 15 20:58:03 CEST 2006
[snip]
> > class Computer:
> > def __init__(self):
> > self.points = 0
> > self.choice = " "
> >
> > def plays(self):
> > comp_choice = random.randint(0,2)
> > if comp_choice == 0:
> > self.choice = 'rock'
> > elif comp_choice == 1:
> > self.choice = 'paper'
> > else:
> > self.choice = 'scissors'
this could be shortened to 'comp_choice =
random.choice(['rock','paper','scissors'])'
More information about the Tutor
mailing list