Over 10 Million Study Resources Now at Your Fingertips


Download as :
Rating : ⭐⭐⭐⭐⭐
Price : $10.99
Language:EN
Pages: 2

Avoid the ambiguity the word copy easiest way clone list use the slice operator

8.11 Aliasing 89
8.11

Aliasing

[ 1, 2, 3 ]

Because the same list has two different names, a and b, we say that it is aliased. Changes made with one alias affect the other:

The easiest way to clone a list is to use the slice operator:

>>> a = [1, 2, 3]
>>> b = a[:]
>>> print b
[1, 2, 3]

90 Lists

As an exercise, draw a state diagram for a and b before and after this change.

8.13 List parameters

The parameter list and the variable numbers are aliases for the same object. The state diagram looks like this:

__main__ numbers

def deleteHead(list):
del list[0]

Here’s how deleteHead is used:

How It Works
Login account
Login Your Account
Add to cart
Add to Cart
Payment
Make payment
Document download
Download File
PageId: ELIE2BFC21
img
Uploaded by :
nLnyKEMD
Page 1 Preview
avoid the ambiguity the word copy easiest way clon
Sell Your Old Documents & Earn Wallet Balance