List

Type "copyright", "credits" or "license()" for more information.
>>> li=["a","b","c","d"]
>>> li
['a', 'b', 'c', 'd']
>>> li.append("new e")
>>> li
['a', 'b', 'c', 'd', 'new e']
>>>

</pre>

<script language="javascript" type="text/javascript">
    // You can place JavaScript like this

</script>
<?php
    // You can place PHP like this

?>
{/source}

Add an item to the end of the list. Equivalent to li[len(li):] = [x]

{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> li=["a","b","c","d"]
>>> li
['a', 'b', 'c', 'd']
>>> li.append("new e")
>>> li
['a', 'b', 'c', 'd', 'new e']
>>> len(li)
5
>>> x = "t"
>>> li[len(li):] = [x]
>>> li
['a', 'b', 'c', 'd', 'new e', 't']
>>> len(li)
6
>>>

</pre
>

<script language="javascript" type="text/javascript">
    // You can place JavaScript like this

</script>
<?php
    // You can place PHP like this

?>
{/source}

list.extend(list2)
{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">
Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> list1 = ['a', 'b', 'c', 'd', 'new e', 't']
>>> list1
['a', 'b', 'c', 'd', 'new e', 't']
>>> list2 = [1, 2, 3]
>>> list2
[1, 2, 3]
>>> list1.extend(list2)
>>> print ("Extend list: ", list1 )
Extend list: ['a', 'b', 'c', 'd', 'new e', 't', 1, 2, 3]
</pre>
<script language="javascript" type="text/javascript">
    // You can place JavaScript like this

</script>
<?php
    // You can place PHP like this

?>
{/source}

Extend the list by appending all the items in the given list. Equivalent to list1[len(list1):] = [list3]

{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> list1 = ['a', 'b', 'c', 'd', 'new e', 't']
>>> list1
['a', 'b', 'c', 'd', 'new e', 't']
>>> list2 = [1, 2, 3]
>>> list2
[1, 2, 3]
>>> list1.extend(list2)
>>> print ("Extend list: ", list1 )
Extend list: ['a', 'b', 'c', 'd', 'new e', 't', 1, 2, 3]
>>> list3 = [4, 5, 6]
>>> list3
[4, 5, 6]
>>> list1[len(list1):] = [list3]
>>> list1
['a', 'b', 'c', 'd', 'new e', 't', 1, 2, 3, [4, 5, 6]]
>>>

</pre>

<script language="javascript" type="text/javascript">
    // You can place JavaScript like this

</script>
<?php
    // You can place PHP like this

?>
{/source}

list.insert(index, item)


list.insert(location,item)

list.insert(4,apple) 4 is the location in list, apple is the object you will insert in list

Insert an item at a given position. The first argument is the index of the element before which to insert, so a.insert(0, x) inserts at the front of the list, .

if you do not give location (position) get Error message

Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
list1.insert ("x", "y")
TypeError: 'str' object cannot be interpreted as an integer

if you give to many item(object, arguments) get Error message

Traceback (most recent call last):
File "<pyshell#20>", line 1, in <module>
list1.insert (3, "z", "x")
TypeError: insert() takes exactly 2 arguments (3 given)

{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> list1 = ['a', 'b', 'c', 'd', 'new e', 't']
>>> list1
['a', 'b', 'c', 'd', 'new e', 't']
>>> list1.insert (3, "z") #------ inserting z at location 3 ------
>>> list1
['a', 'b', 'c', 'z', 'd', 'new e', 't']
>>>

</pre>

<script language="javascript" type="text/javascript">
    // You can place JavaScript like this

</script>
<?php
    // You can place PHP like this

?>
{/source}

list1.insert(len(list1), "x") is equivalent to list1.append(x).

{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> list1 = ['a', 'b', 'c', 'd', 'new e', 't']
>>> list1
['a', 'b', 'c', 'd', 'new e', 't']
>>> list1.insert(len(list1), "x")
>>> list1
['a', 'b', 'c', 'd', 'new e', 't', 'x']
>>>

</pre>

<script language="javascript" type="text/javascript">
    // You can place JavaScript like this

</script>
<?php
    // You can place PHP like this

?>
{/source}

list.remove(z)

Remove the first item from the list whose value is x. It is an error if there is no such item.

{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> list1 = ['a', 'b', 'c', 'z', 'd', 'new e', 't']
>>> list1
['a', 'b', 'c', 'z', 'd', 'new e', 't']
>>> list1.remove('z');
>>> print ("List : ", list1 )
List : ['a', 'b', 'c', 'd', 'new e', 't']
>>> list1.remove('new e');
>>> print ("List : ", list1 )
List : ['a', 'b', 'c', 'd', 't']
>>> list1.remove('t');
>>> print ("List : ", list1 )
List : ['a', 'b', 'c', 'd']
>>>

</pre>

<script language="javascript" type="text/javascript">
    // You can place JavaScript like this

</script>
<?php
    // You can place PHP like this

?>
{/source}

list.pop([i])

Remove the item at the given position in the list, and return it. If no index is specified, a.pop() removes and returns the last item in the list. (The square brackets around the i in the method signature denote that the parameter is optional, not that you should type square brackets at that position. You will see this notation frequently in the Python Library Reference.)

{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> list1 = ['a', 'b', 'c', 'd', 'new e', 't', 'x']
>>> list1
['a', 'b', 'c', 'd', 'new e', 't', 'x']
>>> list1.pop() # If no index is specified, list1.pop() removes and returns the last item in the list.
'x'
>>> list1.pop(4) # Removes position 4, list1.pop(4) removes and returns position 4 'new e'.
'new e'
>>> list1
['a', 'b', 'c', 'd', 't']
>>>

</pre>

<script language="javascript" type="text/javascript">
    // You can place JavaScript like this

</script>
<?php
    // You can place PHP like this

?>
{/source}

list.clear()

Remove all items from the list. Equivalent to del a[:].

{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> list1 = ['a', 'b', 'c', 'z', 'd', 'new e', 't']
>>> list1
['a', 'b', 'c', 'z', 'd', 'new e', 't']
>>> list1.clear()
>>> list1
[]
>>>

>>> #----------------------------------

>>> # -----------Equivalent to del a[:]
>>> list1 = ['a', 'b', 'c', 'z', 'd', 'new e', 't']
>>> list1
['a', 'b', 'c', 'z', 'd', 'new e', 't']
>>> del list1[:]
>>> list1
[]
>>>

</pre>

<script language="javascript" type="text/javascript">
    // You can place JavaScript like this

</script>
<?php
    // You can place PHP like this

?>
{/source}

list.index(x)

Return the index in the list of the first item whose value is x. It is an error if there is no such item.

{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> list1 = ['a', 'b', 'c', 'd', 'new e', 't', 'x']
>>> list1
['a', 'b', 'c', 'd', 'new e', 't', 'x']
>>> list1.index('new e')
4
>>> list1.index('a')
0
>>> list1.index('x')
6
>>>

</pre>

<script language="javascript" type="text/javascript">
    // You can place JavaScript like this

</script>
<?php
    // You can place PHP like this

?>
{/source}

list.count(x)

Return the number of times x appears in the list.

{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> list1 = ['a', 'b', 'c', 'z', 'd', 'new e', 't', 'a']
>>> list1
['a', 'b', 'c', 'z', 'd', 'new e', 't', 'a']
>>> list1.count('a')
2
>>> list1.count('b')
1
>>> list1.count('ab')
0
>>>

</pre>

<script language="javascript" type="text/javascript">
    // You can place JavaScript like this

</script>
<?php
    // You can place PHP like this

?>
{/source}

list.sort()

Sort the items of the list in place.

{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> list1 = ['a', 'b', 'c', 'z', 'd', 'new e', 't', 'a']
>>> list1
['a', 'b', 'c', 'z', 'd', 'new e', 't', 'a']
>>> list1.sort()
>>> list1
['a', 'a', 'b', 'c', 'd', 'new e', 't', 'z']
>>>

</pre>

<script language="javascript" type="text/javascript">
    // You can place JavaScript like this

</script>
<?php
    // You can place PHP like this

?>
{/source}

list.reverse()

Reverse the elements of the list in place.

{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> list1 = ['a', 'b', 'c', 'z', 'd', 'new e', 't']
>>> list1
['a', 'b', 'c', 'z', 'd', 'new e', 't']
>>> list1.reverse()
>>> list1
['t', 'new e', 'd', 'z', 'c', 'b', 'a']
>>>

</pre>

<script language="javascript" type="text/javascript">
    // You can place JavaScript like this

</script>
<?php
    // You can place PHP like this

?>
{/source}

list.copy()

Return a shallow copy of the list. Equivalent to a[:].

{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> list1 = ['a', 'b', 'c', 'z', 'd', 'new e', 't']
>>> list1
['a', 'b', 'c', 'z', 'd', 'new e', 't']
>>> list.copy(list1)
['a', 'b', 'c', 'z', 'd', 'new e', 't']
>>> #------------------------------
>>> #------------------------------
>>> # ---- Equivalent to a[:]----
>>>
>>> list1[:]
['a', 'b', 'c', 'z', 'd', 'new e', 't']
>>>

</pre>

<script language="javascript" type="text/javascript">
    // You can place JavaScript like this

</script>
<?php
    // You can place PHP like this

?>
{/source}