Difference between append and extend.

If you are confused between the append and extend methods, the following example will clear your doubts:

>>> Linux  = ["kali", "Ubuntu", "debian"]

>>> Linux2 = ["RHEL", "Centos"]

>>> Linux.extend(Linux2)

>>> Linux

['kali', 'Ubuntu', 'debian', 'RHEL', 'Centos']

>>>

>>>

>>> Linux = ["kali", "Ubuntu", "debian"]

>>> Linux2 = ["RHEL", "Centos"]

>>> Linux.append(Linux2)

>>> Linux

['kali', 'Ubuntu', 'debian', ['RHEL', 'Centos']]

>>>

The append method gives a list within the list. The list Linux2 = ["RHEL", "Centos"] has been taken as one list. Let's proceed to the next method.

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

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