Beginner Question

Kevin Reeder avail at uponrequest.org
Fri Mar 28 04:03:40 CET 2003


On Thu, 27 Mar 2003 18:23:12 -0800, Garry Knight wrote:

> Kevin Reeder wrote:
> 
>>       self.cards[i], self.cards[j] = self.cards[j], self.cards[i]
>> 
>> The problem is to rewrite the last line without using a sequence
>> assignment.
> 
> One way is by using a temporary variable:
>         t = self.cards[i]
>         self.cards[i] = self.cards[j]
>         self.cards[j] = t
> 
> 
And that may be what they're getting at as a way to make me analyze the
process, but isn't the sequence assignment more or less an abbreviated way
of doing the same thing? I've been thinking that there is some other
way that is eluding me.

Kevin




More information about the Python-list mailing list