@@ -33,6 +33,7 @@ print(color)
3333#### append a another list :page_with_curl :
3434Example:
3535``` python
36+ # initilize two list
3637color= [' black' ,' red' ]
3738color2= [' brown' ,' green' ]
3839
@@ -45,7 +46,10 @@ You can not append more than one element at a time using append
4546
4647This is wrong example:
4748``` python
49+ # initilize list
4850color= [' black' ,' red' ]
51+
52+ # Try to Append Two element at time
4953color.append(' brown' ,' green' )
5054# Result Error:-append() takes exactly one argument (2 given)
5155```
@@ -68,6 +72,7 @@ Both position and element are required element
6872
6973Example:
7074``` python
75+ # initilize list
7176color= [' black' ,' red' ,' brown' ]
7277
7378# insert 'green' element at 1 st position
@@ -95,7 +100,9 @@ print(num)
95100
96101Example:
97102``` python
103+ # initialize num list
98104num= [1 ,3 ,4 ,7 ]
105+
99106# insert 8 element at -10th position
100107num.insert(- 10 ,8 )
101108
@@ -111,8 +118,11 @@ list1.extend(lst2)
111118```
112119Example:
113120``` python
121+ # initilize two list
114122num1= [1 ,3 ,4 ,7 ]
115- nun2= [8 , 9 ]
123+ num2= [8 , 9 ]
124+
125+ # add num2 list to num1
116126num1.extend(num2)
117127print (num1)
118128
@@ -138,6 +148,7 @@ del list or element position
138148
139149Example:
140150``` python
151+ # initilize list
141152number= [1 ,3 ,4 ,7 ,8 , 9 ]
142153# Delete 4 from above list
143154del number[2 ]
@@ -150,7 +161,10 @@ print(number)
150161
151162### How to delete list
152163``` python
164+ # initilize list
153165number= [1 ,3 ,4 ,7 ,8 , 9 ]
166+
167+ # delete total list
154168del number
155169
156170print (number)
@@ -170,6 +184,7 @@ listname.pop(position)
170184```
171185Example:
172186``` python
187+ # initilize list
173188number= [1 ,3 ,4 ,7 ,8 , 9 ]
174189# remove 8 element which present 4 or -2 index
175190del_val= number.pop(4 )
@@ -187,7 +202,7 @@ Example
187202number= [1 ,3 ,4 ,7 ,8 , 9 ]
188203number.pop(100 )
189204
190- # Result:error will occured.
205+ # Result:error will occured. pop index out of range
191206```
192207
193208
@@ -201,6 +216,7 @@ listname.remove(value)
201216```
202217Example:
203218``` python
219+ # initilize list
204220color= [' red' , ' green' , ' blue' ]
205221
206222# Remove "green " From list
@@ -216,7 +232,9 @@ print(color)
216232
217233Example:
218234``` python
235+ # initilize list
219236color= [' red' , ' green' , ' blue' ]
237+
220238# remove "black" From above list
221239color.remove(" black" )
222240
@@ -232,6 +250,7 @@ list[index]="new value"
232250```
233251Example:
234252``` python
253+ # initilize list
235254color= [" blue" ," green" ," red" ]
236255
237256# update blue with *black*
@@ -244,4 +263,3 @@ print(color)
244263```
245264
246265- If you provide out of range index while updating value then it will generate out of range index error
247- In next tutorial I will write some remaining methods on list
0 commit comments