what does extend do in python

Solutions on MaxInterview for what does extend do in python by the best coders in the world

showing results for - "what does extend do in python"
Giovanni
24 Apr 2017
1#adding two or more elements in a list
2list1 = [1,2,3,4,5]
3list1.extend([6,7,8])
4print(list1)
5#output = [1, 2, 3 ,4 ,5, 6, 7, 8]
Nicola
04 Sep 2017
1# Difference between .append() and .extend() in python
2# .extend explained below :)
3
4list = ['hello', 'bro'] 
5my_list.append('append') 
6
7print (my_list)
8>>> ['geeks', 'for', 'geeks']
9
10my_list.append ([6, 0, 4, 1])
11
12print (my_list)
13>>> ['geeks', 'for', 'geeks', [6, 0, 4, 1]]
14
15# For list.extend, each element of an iterable gets appended 
16# to my_list
17
18my_list = ['geeks', 'for'] 
19another_list = [6, 0, 4, 1] 
20my_list.extend(another_list) 
21
22print (my_list)
23>>> ['geeks', 'for', 6, 0, 4, 1]
24
25# NOTE: A string is an iterable, so if you extend
26# a list with a string, you’ll append each character
27# as you iterate over the string.
28
29my_list = ['geeks', 'for', 6, 0, 4, 1] 
30my_list.extend('geeks') 
31
32print (my_list)
33>>>['geeks', 'for', 6, 0, 4, 1, 'g', 'e', 'e', 'k', 's']
34
35# and yup I have copied it.
36# Originally by Yvant2000
Ashton
24 Nov 2017
1The extend() method adds the specified list elements (or any iterable) to the end of the current list.
queries leading to this page
how to extend inside list pythonextend pypython extendpython difference between extend and appendextend in list python 3how to extend list in pthonextend methodwhat does list extend do in pythonextend method in a listpython exntedwhat is extend in pythonextend function in listwhen we use a value extend in python extend python listhow to extend a new list from another list in pyhtonhow to use extend in pythonextend python examplehow extend methods works in pythonpython3 list extendhow to extend the list in pythonextende list methoshow to extend list pythonpython list extendpython extendpython list extend example extend 28 29 pythonpython array extendextend 28 29 pythonextend method in python listlist extendwhat uses extend 28 29 in pythonpython list of list extendextend list method pythonexpand in pythonextend list of lists into listhow to use extend list in pythonlist extend python in javacan we extend our list in pythonopposite of extend in pythonuse of extend 28iterable 29 in python extend 28 29 in pythonwhat is similar to extend in pythonextend list top pythonlist extend in python to create new variablepython list extend string in placelist extendsextend certain methods in pythonuse of python extend extend 28iterable 29extend use in pythonnwhat does extend do pythonhow to extend an empty list from another list in python extended pythonpython extendsextend a list in pythonlist extend function in setpython expend a listlist extends in pythonhow can i write extend methods in pythonextend in python 3extend list function pythonpython list extendhow to extend functionextending lists pythonextend in pythonlsit extendwhat does extend mean in pythonextends collection pyhtonhow to extend listlist extend python examplea extends 28b 29 in pythondoes extend methon in python return a value 3fusing extend in pythonextend 28 29 in pythonarray extend not function pythonlist extend pythonlist extendpython extend all forspython extend list methodexctend python listextend a list pythonextend a single value in list in python extend 28 29extend the list in pythonextend list into list pythonextend pthon listextend python list extend oythonwhat does extend do in pythonhow to extend a list using a listexpand list in pythonextend pythonpython extend list 3fextend python list elementpython list extednpython expand listpython list extend stringextend in oythonhow to extend python listcreate function to extend a list pythonpython extend method 27 2a 27 extend in pythonlist all addall pythonhow to use list extend in pythonexample of list extend python in a functionextend 28 29 pyhtonhow to extend an empty list from another listpython expand array outputhow to extend list in pythonhow to extend a list in python without extendlist extend pythonlist extendspython list extent methodsyntax of extend in python extend python 3extend in list python extend list pythonpython program for list extend 28list2 29lpython extend function lista extend pythonexpand python 2cextend 28 29 pythonexpond listlist set extend pythonpython list extebdpython 2 7 list extend 28 29python list extend 3fpython list extend 28 29 methodlist extend in pythonpython list extendpython extendextends in pythonexpand listpython not able to extend a list with listhow to extend a string into a list pythonextend the list class in pythonextend for python pythonhow to extend a function in pythonextend for list in pythonpython list 2cextendwithout extend function extend the list with another list in pythonpython list extend a listextend for a list in pythonwhat is extend pyextend listwhat is extend in python in classthe extend 28 29 in python meansextend in listextend function in listsextends pythonextend list in python 3list extends python extend in pythonlsit extend pythonlist extend function pythonpython extend a listextend in python listhow to extend a list in pythonhow to extend a list in python without extendpython list expandextend list in pythonpython extend arraypython extend list by itselfextend method in listpython extend lsitpython how to extend a function extend in listextend lost pythonlist extend pythonwhat does extend do in pythonwhat does extend do in phythonarray extend not function python functionextend function lists pythonpython extend lisextend pthonextend method of list in pythonextend function in python w3schoolsextend class pythonpython extend listpython extend functionswhat is the use of extend in pythonextend 28 29extend elements in list in javapython extedhow to extend an empty list in pythonpython extend function examplepython extendpytrhon 3 extend 28 29append in python equivalent to cpython extend usagelist expandpython extend nedirextend a list in to another listextend function in python extend pythonextend inpythonextend method in pythonlist extend list pythonpython function extend extend syntax in pythonextend function in python list exstend 28 29python list extend 28 29list extend 28 29 extend in pythonmore about extend in pythonpyhton extendextend python syntaxpython extend 28 29use of extend in pythonpython extend list of listsextende in pythonextend a single value list in pythonpyton list extendlista extendhow to extend functions in pythonpython extend functionpython expandlist extend pythnonextend in pyhtonextend list python inside listpython extend list classpython who is extendedlist extend in pythonpython extend methodspython list extend methodwhat does extend in pythonpython extendextend function pythonhow to extend a listextend python methodhow to append a variable in an object pyhtonexttend pythonpython exetendpyhon extend methodlist append vs list extendextends in list python extend 28 29 pylist extend other listextend method pythonextend usae in python extend list pythonand append lsit of listsextend command in pythonpyhton list extend 2blist extend 28l 29python list extends expand pythonarray extendpython3 extend listextend list pythonextend a listhow to get extend 28 29 in pythonwhen to extend in pythonextend in place pythonhow extend works in pythonwhat does extend in python meanextend python functionlist extandpython extande arraypython extends listextend in python listsextend 2 items to list pythonpython class extendwhat is extend in pythonpython append vs extendwhat is list extend in pythonlist extend functionhow to use extend in list in pythonlist extend python 3expand list pythonarray extend pythonpython 5b 5d extendpython what does extend doextend elements of list to listpyton list extendpython lists extendhow to use the extend function does extend python use referenceoython extendhow can i write extend methods on pythonlist expendextend example in pythonextend list python meaningwhat does extend do in python