Re: [Tutor] [Tutor} Why doesn't it choose a new number each time?

2007-02-15 Thread Alan Gauld
"Geoframer" <[EMAIL PROTECTED]> wrote > Probably this is not unlike Alan suggest, but i got confused when i > read > about tables. Unless he means dictionaries instead. I meant tables in a generic sense. I actually started using a dictionary then changed to a list because its more generic.. But

Re: [Tutor] [Tutor} Why doesn't it choose a new number each time?

2007-02-15 Thread Geoframer
The one thing people told me when i started learning python was that python has this lovely structure called dictionaries. Your particular problem is very easy to solve using dictionaries in about 12 lines (i coded it myself just to see ;-)). For instance you could define the various values as a

Re: [Tutor] [Tutor} Why doesn't it choose a new number each time?

2007-02-15 Thread Luke Paireepinart
Rikard Bosnjakovic wrote: > On 2/15/07, Nathan Pinno <[EMAIL PROTECTED]> wrote: > > >> and that was a suggestion. (Thanks!) But can anyone explain why I can >> shorten the code? I looked at it a long while yesterday, and came up with >> nothing. The only thing I decided was to try to get it to t

Re: [Tutor] [Tutor} Why doesn't it choose a new number each time?

2007-02-15 Thread Rikard Bosnjakovic
On 2/15/07, Nathan Pinno <[EMAIL PROTECTED]> wrote: > and that was a suggestion. (Thanks!) But can anyone explain why I can > shorten the code? I looked at it a long while yesterday, and came up with > nothing. The only thing I decided was to try to get it to the GUI stage. If you take a look at

Re: [Tutor] [Tutor} Why doesn't it choose a new number each time?

2007-02-15 Thread Alan Gauld
"Nathan Pinno" <[EMAIL PROTECTED]> wrote > But can anyone explain why I can shorten the code? There are a few things you could do but one very powerful trick is to use a table driven approach. Thus: rps = {0:'rock',1:'paper',2:'scissors'} # use zero to match list index results = [

Re: [Tutor] [Tutor} Why doesn't it choose a new number each time?

2007-02-15 Thread Nathan Pinno
GUI stage. Thanks, Nathan > Date: Wed, 14 Feb 2007 17:17:57 +0100> From: "Rikard Bosnjakovic" <[EMAIL > PROTECTED]>> Subject: Re: [Tutor] Why doesn't it choose a new number each > time?> To: tutor@python.org> Message-ID:> <[EMAIL PROTECTED]>>

Re: [Tutor] Why doesn't it choose a new number each time?

2007-02-14 Thread Rikard Bosnjakovic
On 2/14/07, Alan Gauld <[EMAIL PROTECTED]> wrote: > I don't think that's a problem. The fact that the computers numbers > don't correspond with the users numbers shouldn't matter provided > the 'if' tests align with the choice result, which they do. Alan, You're right, ofcourse. I approached the

Re: [Tutor] Why doesn't it choose a new number each time?

2007-02-14 Thread Alan Gauld
"Rikard Bosnjakovic" <[EMAIL PROTECTED]> wrote > On 2/14/07, Nathan Pinno <[EMAIL PROTECTED]> wrote: > >> I wrote a rock, paper, scissors game and every time you play >> without >> exiting, it chooses the same number. How can I fix this problem? >> The >> relative code is below: > [...] >>

Re: [Tutor] Why doesn't it choose a new number each time?

2007-02-13 Thread Rikard Bosnjakovic
On 2/14/07, Nathan Pinno <[EMAIL PROTECTED]> wrote: > I wrote a rock, paper, scissors game and every time you play without > exiting, it chooses the same number. How can I fix this problem? The > relative code is below: [...] > compchoice = choice(range(3)) [...] >>> range(3) [0, 1, 2]

Re: [Tutor] Why doesn't it choose a new number each time?

2007-02-13 Thread wesley chun
> I wrote a rock, paper, scissors game and every time you play without > exiting, it chooses the same number. How can I fix this problem? The > relative code is below: >: > compchoice = choice(range(3)) hey nathan, neat program... that's one of the homework assignments in my boo

Re: [Tutor] Why doesn't it choose a new number each time?

2007-02-13 Thread Alan Gauld
"Nathan Pinno" <[EMAIL PROTECTED]> wrote > I wrote a rock, paper, scissors game and every time you play > without exiting, it chooses the same number. How can I fix this > problem? The relative code is below: I can't see anything obvious, can you be more specific. Which number does it always cho

[Tutor] Why doesn't it choose a new number each time?

2007-02-13 Thread Nathan Pinno
Hey all, I wrote a rock, paper, scissors game and every time you play without exiting, it chooses the same number. How can I fix this problem? The relative code is below: [code] # -*- coding: cp1252 -*-from random import * print "Welcome to Rock, Paper, or Scissors!"print "by Nathan Pinno"pr