Multiplication of lists

By using the * operator, you can perform multiplication of Python lists, as shown in the following example:

>>> Av = ['Vision', 'sam']

>>> new_Av = Av*2

>>> new_Av

['Vision', 'sam', 'Vision', 'sam']

Let us see the memory address of the new list.

>>> id(new_Av[0])

47729312

>>> id(new_Av[2])

47729312

>>>

In this case, the memory address of both the index values is the same.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.79.176