> what is the difference between the two ways of assigning the list?
> p=a vs. p=a[:]

The first makes p point at the same list as a.
The second makes p point at a *copy* of the list pointed to by a.

You will see the difference if you try to modify the lists after assignment.
In the first case modifying either variable will affect both variables 
values.
In the second changing p will not affect a.

This is one of the common 'gotchas' of Python programjming.

Alan G
Author of the learn to program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to