Newbie-list-problem: how to supress constraining 2 lists - a=b ?
JohnJacob
JJ at JJ.com
Fri Nov 8 05:40:41 EST 2002
"HugOnline" <thehugonline at yahoo.de> wrote in message
news:813cfe33.0211080235.5d4b8c9e at posting.google.com...
> Hello,
>
> I'm a Python - newbie and I can not solve the following problem:
>
> >>>a=[8,7,6,5,4] # set this list to a
> >>>b=a # I' want to have two same lists: a and b
> >>>b.sort() # b should be sorted
> >>>print b # it's ok
> [4,5,6,7,8]
> >>>print a
> [4,5,6,7,8] # but a is sorted, too !!!
>
> How can I suppress the constraining of a and b? I want to have in the
> result two list - a unsorted and b sorted. Is there a switch to supress
> it?
>
> Regards HugOnline
>
b = a[:]
More information about the Python-list
mailing list