Python List extend() MethodPython extend() method extends the list by appending all the items from the iterable. Iterable can be a List, Tuple or a Set. Examples are described below. SignatureParametersx: Iterable type parameter. ReturnIt does not return any value rather modifies the list. Let's see some examples of extend() method to understand it's functionality. Python List extend() Method Example 1It is a simple example to describe the use of extend method. Output: 1 2 3 After extending: 1 2 3 4 Python List extend() Method Example 2We can pass list as an element and the list will be extended. See the example below. Output: 1 2 3 After extending: 1 2 3 4 5 6 Python List extend() Method Example 3 : TupleIt can be possible that the element is a tuple type and the list extends itself by tuple elements. See the example below. Output: 1 2 3 After extending: 1 2 3 4 5 6 Python List extend() Method Example : SetIt can be possible that the element is a Set type and the list extends itself by Set elements. See the example below. Output: 1 2 3 After extending: 1 2 3 6 5 4
Next TopicPython Lists
|
JavaTpoint offers too many high quality services. Mail us on [email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected]
Duration: 1 week to 2 week