Skip to content

extend method in python

Use Python’s list.extend(iterable) to append each item from another iterable to an existing list. Unlike append(), extend() adds the iterable’s elements individually and returns None. Python list.extend() syntax and return value list1.extend(list2) The general syntax is items.extend(iterable). It takes exactly one iterable argument, appends its elements in iteration order, changes items in place and returns None. Do not assign items = items.extend(other), because that replaces the variable with None. Tuples,… Read More »Python list.extend(): Add Multiple Items from an Iterable

Python list.extend(): Add Multiple Items from an Iterable