DigitalOcean Referral Badge
Udit Vashisht
Author: Udit Vashisht


How to append to a list in Python ? - Python List append() method

  • Less than a minute read
  • 456 Views
How to append to a list in Python ? - Python List append() method

    Table of Contents

Python List append() method

The Python list append() method adds an item to the end of the list. The length of the list increase by one.

Syntax of append()

The syntax for the same is :-

list_name.append(item)

Parameters of append()

The method takes only a single argument

item - an item to be added at the end of the list

The item can be any object like number, string, dictionary, list, set, boolean, etc.

Return value of append()

The append() method doesn’t return anything and just changes the list inplace. Hence, it returns None.

Example of appending an element to a list

color_list = ['red', 'yellow', 'blue']
color_list.append('green')

print(color_list)
['red', 'yellow', 'blue', 'green']

Example of appending a list to a list

color_list.append(['black', 'white'])

print(color_list)
['red', 'yellow', 'blue', 'green', ['black', 'white']]

Related Posts

Chapter 4 - Print function
By Udit Vashisht

How to use Python print() function?

In the early days of your python learning, one function that you are going to use the most is the print() function. So, I have decided to add it in the opening chapter of this tutorial. In addition to the print function, you ...

Read More
Scatter Plotting in Python | Matplotlib Tutorial | Chapter 7
By Udit Vashisht

Scatter Plot in Python using Pandas and Matplotlib

In this tutorial we will learn to create a Scatter Plot in Python using Matplotlib and Pandas. We will use matplotlib.pyplot()’s plt.scatter() to create the scatter plot

What is a Scatter Plot?

Scatter Plot also known as scatter plots ...

Read More
Python Realtime Plotting | Matplotlib Tutorial | Chapter 9
By Udit Vashisht

Python Realtime Plotting in Matplotlib

Python Realtime Plotting | Chapter 9

In this tutorial, we will learn to plot live data in python using matplotlib. In the beginning, we will be plotting realtime data from a local script and later on we will create a python live plot ...

Read More
Search
Tags
tech tutorials automate python beautifulsoup web scrapping webscrapping bs4 Strip Python3 programming Pythonanywhere free Online Hosting hindi til github today i learned Windows Installations Installation Learn Python in Hindi Python Tutorials Beginners macos installation guide linux SaralGyaan Saral Gyaan json in python JSON to CSV Convert json to csv python in hindi convert json csv in python remove background python mini projects background removal remove.bg tweepy Django Django tutorials Django for beginners Django Free tutorials Proxy Models User Models AbstractUser UserModel convert json to csv python json to csv python Variables Python cheats Quick tips == and is f string in python f-strings pep-498 formatting in python python f string smtplib python send email with attachment python send email automated emails python python send email gmail automated email sending passwords secrets environment variables if name == main Matplotlib tutorial Matplotlib lists pandas Scatter Plot Time Series Data Live plots Matplotlib Subplots Matplotlib Candlesticks plots Tutorial Logging unittest testing python test Object Oriented Programming Python OOP Database Database Migration Python 3.8 Walrus Operator Data Analysis Pandas Dataframe Pandas Series Dataframe index pandas index python pandas tutorial python pandas python pandas dataframe python f-strings padding how to flatten a nested json nested json to csv json to csv python pandas Pandas Tutorial insert rows pandas pandas append list line charts line plots in python Django proxy user model django custom user model django user model matplotlib marker size pytplot legends scatter plot python pandas python virtual environment virtualenv venv python python venv virtual environment in python python decorators bioinformatics fastafiles Fasta python list append append raspberry pi editor cron crontab Cowin Cowin api python dictionary Python basics dictionary python list list ios development listview navigationview swiftui ios mvvm swift environmentobject property wrapper @State @Environm popup @State ios15 alert automation instagram instaloader texteditor youtubeshorts textfield multi-line star rating reusable swift selenium selenium driver requests-html youtube youtube shorts python automation python tutorial algo trading nifty 50 nifty50 stock list nifty50 telegram telegram bot dictionary in Python how to learn python learn python