Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Exchanging the content of 2 variables
- In most languages, exchanging the content of two variable involves using a temporary variable.
- In Python, this can be done with multiple assignment.
- """
- >>> a=3
- >>> b=7
- >>> (a,b)=(b,a)
- >>> print a
- 7
- >>> print b
- 3
- In Python, tuples, lists and dictionnaries are your friends, really !
- Highly recommended reading: Dive into Python (http://diveintopython.org/). The first chapter contains a nice tutorial on tuples, lists and dictionnaries. And don't forget to read the rest of the book (You can download the entire book for free).
- """
Advertisement
Add Comment
Please, Sign In to add comment