Python lists

April 27, 2013
programming python

Spent some time scribbling about Python lists today.

Python lists can hold values of mixed data type. They can be fully manipulated and any element can be called from the list at will.

Creating a list is as simple as putting comma-separated values between square brackets.

mylist = [1,2,3,4,5]

Now playing around with lists is fun. Here are methods to add & remove items.

Adding an item to the end of the list.

mylist.append(item)

Insert an item at a given position by specifying the index value.

mylist.insert(index,item)

Remove the first occurrence of an item in the list.

mylist.remove(item)

Remove the item at the given position (index). If no index value is specified, i.e using mylist.pop() then the right-most item is removed which is also the last index.

mylist.pop(index)

Return index of first occurrence of the given item.

mylist.index(item)

Count number of occurrences for given item.

mylist.count(item)

Sort items of the list in place.

mylist.sort()

Reverse elements of the list.

Functional Programming by Renghen

May 28, 2017
programming meetup mauritius-software-craftsmanship-community

braincheck() perl script

March 4, 2014
linux programming

Visual Studio 2013 virtual launch

November 19, 2013
windows programming user-groups-mauritius journal microsoft