"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
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
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
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
"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 = [
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]>>
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
"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:
> [...]
>>
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]
> 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
"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
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
12 matches
Mail list logo