assistance with python coding

John Purser jmpurser at gmail.com
Mon Sep 11 13:09:33 EDT 2006


On Mon, 2006-09-11 at 11:23 -0500, John Shappell wrote:
> I don’t understand what this question is asking; can you clarify for
> me and maybe point me in the right direction?
> 
>  
> 
> As an exercise, rewrite this line of code without using a sequence
> assignment. 
> 
> self.cards[i], self.cards[j] = self.cards[j], self.cards[i]
> 
>  
> 
> V/R
> 
>  
> 
> CW2 John Shappell
> 
> 931-980-4707
> 
> FAX 775-618-2455
> 
> john.j.shappelljr at us.army.mil
> 
>  
> 
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list

John,

Sequence assignment is a way of assigning multiple values at once.  In
your example above (adjusted to cut down on typing):
i = 'dog'
j = 'cat'
i, j = j, i

Now:
i == 'cat'
j == 'dog'

The assignment (I believe) is to come up with the same result WITHOUT
using sequence assignment which usually requires some form of temporary
variable to hold the values in the middle while they switch.

Where are you stationed?  Feel free to reply via my gmail account.

John Purser





More information about the Python-list mailing list