Title: Message
Dear John,
 
This is a switch.  In other words if you have two variables, a and b, switch the values.  The author of the exercise is trying to point out that without the sequence operation, you must do it the same way as in nearly all other languages.  That is:
 
tmp = a
a = b
b = tmp
 
Python gives you the ability to switch two variables with just a single statement.  To perform the above with a sequence assignment would be:
 
a, b = b, a
 
Your example only slightly complicated this by using an array.  The answer you are looking for is:
 

tmp = self.cards[i]

self.cards[i] = self.cards[j]

self.cards[j] = tmp

 
Let me know if you need any more help!
 
Yours truly,
Richard Morello
 
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of John Shappell
Sent: Monday, September 11, 2006 12:23 PM
To: python-list@python.org
Subject: assistance with python coding

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

[EMAIL PROTECTED]

 

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to