Python Lists And List Functions

Lists :

Python lists are container that is used to store a list of values of any data type. In simple words we can say that list is a collection of any data type items or elements.

E.g. list1 [‘harry’, ‘ram’, ‘Aakash’, ‘shyam’, 5, 4.85]

The above list contains strings, integer and even float type data. It means above list contains any kind of data means it’s not mandatory to form list of only one data type. List can contain any kind of data in it.

List elements are also accessed by using Indexes i.e. first element of list possess 0 index then second as 1 and so on.

Note : if you put any index which isn’t in the list i.e. that index is not there in list then you will get an error.

List Methods :

Here is the list of list methods of Python.

List Slicing :

List slices, like string slices are the sub part of a list extracted out. You can use indexes of list elements to create list slices as per following format :


Here also slicing will go from start index to stop index-1. It means from specified start index to specified stop index – 1.

List Methods :

Types of Data Types :

Tuple :

Tuple is an immutable data type in Python. Tuple is a collection of elements enclosed in () (parentheses). Tuple once defined can’t be changed i.e. its elements or values can’t be altered or manipulated.

Note: To create tuple of one element it is necessary to put ‘,’ after that one element i.e. like this tup=(1,) because if we write only 1 then interpreter will understand it as a simple number or integer that’s why it’s important to use ‘,’ after single element.

Swapping of two numbers :

Code file as described in the video

grocery = ["Harpic", "vim bar", "deodrant", "Bhindi",
           "Lollypop", 56]
# print(grocery[5])
numbers = [2, 7, 9, 11, 3]
# numbers.remove(9)
# numbers.pop()
# numbers.sort()
# numbers = []
# numbers.reverse()
# numbers.append(1)
# numbers.append(72)
# numbers.append(5)
# numbers.insert(2, 67)
# print(numbers)
# 3, 11, 9, 7, 2
# print(numbers)
# numbers[1] = 98
# print(numbers)
# Mutable - can change
# Immutable - cannot change
# tp = (1,)
# print(tp)
a= 1
b = 8
a, b = b,a
# temp = a
# a = b
# b = temp
print(a, b)


Raheel123 10 months, 3 weeks ago
Sir you have a lot of likes
ahmedraza 3 months, 3 weeks ago
anubhavs921 3 months ago
Very Nice tutorial and better explain of lists.......thanku sir
abcd 3 weeks, 1 day ago
sanayasingh 2 months, 2 weeks ago
cosmeticitem= ["serum","facewash","lip bam","face mask","facesheet","Toner"] cosmeticitem.sort() print(cosmeticitem) output= ['Toner', 'face mask', 'facesheet', 'facewash', 'lip bam', 'serum'] can you explain why toner comes first in output ?
A.Basit 2 months, 2 weeks ago
gr8 job...thks...
Vivek-Mishra 1 week, 6 days ago
Full Notes and Source Code ::::::::::} |::::::::::::| Thanks, Harry Bhai for Awesome Tutorials


  1. File - Download here
  2. File - Download here
  3. File - Download here
  4. File - Download here
  5. File - Download here
  6. File - Download here

Course Announcements

Any Course related announcements will be posted here

Course Content