Top Built-in Functions for Python Data Structures.

Rajan Sahu
6 min readMar 24, 2022

My article is for everyone! Non-members can click on this link and jump straight into the full text!!

Today, we are going to learn about some of the most useful built-in functions in Python for common secondary data types or data structures. When I was in college I wrote everything from scratch (as is common for people who migrated to Python from lower-level computer languages like C/C++ and Java) which led me to waste a considerable amount of time re-writing functions and features that had already been included in the language itself.

Then I came across built-in functions in Python and I started using them; this led to my code being more efficient, more readable.

Python has a set of built-in methods that you can use on lists.

append()

  • It is used to insert an element to the end of a list.
fruit_list =['apple','banana','orange']
fruit_list.append('grapes')
print(fruit_list)
> ['apple', 'banana', 'orange', 'grapes']

clear()

  • It is used to remove all the elements from the list.
fruit_list =['apple','banana','orange']
fruit_list.clear()
print(fruit_list)

--

--

Rajan Sahu
Rajan Sahu

Written by Rajan Sahu

Backend and Data Engineer by Day; Teacher, Friend and Content-Writer by night.

No responses yet