EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Software Development Software Development Tutorials Python Lists Tutorial Python List Functions
 

Python List Functions

Lalita Gupta
Article byLalita Gupta
EDUCBA
Reviewed byRavi Rathore

Python-List-Functions

Introduction to Python List Functions

There are different types of data types in python like Tuple, Set, Dictionary, etc. The one that is both changeable and ordered is called List in Python. It also allows duplicate values as a member, wherein each member can be accessed separately in an iterative fashion. In this topic, we are going to learn about Python List Functions.

 

 

Below is the basic syntax to define a list:

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

List = ["grapes" , "mangoes" , "bananas" ,"kiwi"]
print(List)

Output:

Python List Functions output 1

Examples of Python List Functions

Let’s discuss the various functions that can be applied.

1. In Operator

It is utilized to verify whether any specific element is a member of the list or not.

Code:

# Python code to showcase the usage of in operator
lst = [1 , 6 , 7 , 4 , 3]
# checking using in operator
if 1 in lst:
    print ("1 is present in the list")
else : print ("1 is not present in the list")

Output:

Python List Functions output 2

2. Not In Operator

It is utilized to verify whether any specific element is not a member of the list.

Code:

# Python code to showcase the usage of not in operator
lst = [1 , 6 , 7 , 4 , 3]
# checking using not in operator
if 1 not in lst:
    print ("1 is not present in the list")
else : print ("1 is present in the list")

Output:

Python List Functions output 3

  • len(): This function returns the length of the list passed as an argument.
  • min():  This function returns the minimum element of the list passed as an argument.
  • max():  This function returns the maximum element of the list passed as an argument.

Let’s take an example to understand the same:

Code:

# Python code to showcase the usage of len(), max() & min() function
lst = [1 , 6 , 7 , 4 , 3]
print(len(lst))
print(min(lst))
print(max(lst))

Output:

Python List Functions output 4

3. + Operator

This operator is utilized to append the members of two lists together in a single one.

Code:

# Python code to understand how + operator works with lists
#  creating list 1
lst = [34 , 37 , 39]
#  creating list 2
lst2 = [43 , 45 , 47]
# using + operator in python to concatenate lists
lst3= lst + lst2
print(lst3)

Output:

Python List Functions output 5

4. * Operator

This operator is utilized to repeat the members of the list the times the operator is used with * operator.

Code:

# Python code to understand how * operator works with lists
# creating list 1
lst = [34 , 37 , 39]
# using * operator in python to concatenate lists
lst3= lst * 2
print(lst3)

Output:

Python List Functions output 6

  • count(): This function returns the number of times an element is present in the list

Code:

# Python code to understand how count() function works with lists
# creating list 1
lst = [34 , 37 , 39 , 24 , 37, 37, 37, 37, 37, 37 , 37 ,37]
# using count() function with lists to understand its usage
print(lst.count(37))

Output:

Python List Functions output 7

  • remove(): This function is utilized to remove the first occurrence of the specified member from the list

Code:

# Python code to understand how remove() function works with lists
# creating list 1
lst = [34 , 37 , 39 , 24 , 37, 37, 37, 37 , 37 , 37 , 37 , 37, 37 , 37]
# using remove() function with lists to understand its usage
lst.remove(37)
print(lst)

Output:

output 8

Here if we notice carefully, the very first occurrence of 37 is removed from the list

  • sort(): This python function is utilized to sort the list passed as an argument in ascending order.

Code:

# Python code to understand how sort() function works with lists
# creating list 1
lst = [34 , 37 , 39 , 24 , 37, 34, 35, 38 , 36 , 33 , 17 , 25, 86 , 47]
# using sort() function with lists to understand its usage
lst.sort()
print(lst)

Output:

output 9

  • reverse(): This python function is utilized to reverse the list passed as an argument.

Code:

# Python code to understand how sort() function works with lists
# creating list 1
lst = [34 , 37 , 39 , 24 , 37, 34, 35, 38 , 36 , 33 , 17 , 25, 86 , 47]
# using sort() function with lists to understand its usage
lst.reverse()
print(lst)

Output:

output 10

  • clear(): This function is utilized to empty the list passed as an argument to this function.

Code:

# Python code to understand how sort() function works with lists
# creating list 1
lst = [34 , 37 , 39 , 24 , 37, 34, 35, 38 , 36 , 33 , 17 , 25, 86 , 47]
# using sort() function with lists to understand its usage
lst.clear()
print(lst)

The Output of this python program is:

output 11

Conclusion

There are various functions applicable to Python Lists that usually help us modify, append, sort, clear, and implement multiple other operations on the lists in python to achieve the business-specific operations within python.

Recommended Articles

This is a guide to Python List Functions. Here we discuss the Examples of Python List Functions along with the syntax and outputs. You may also have a look at the following articles to learn more –

  1. Lowercase in Python
  2. Python Substring
  3. Python Countdown Timer
  4. Python String Operations

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW