The list in Python supports all data types. You can add any type of data you want to an existing list without minding the types of other elements included in it. In this article, we will learn how to add a float to a list in Python with the help of 3 methods. Scroll down to learn!
How to add a float to a list in Python?
Use the 3 following methods to add a float to a list in Python:
Using .append()
The method .append()
is the best choice if you want to add a float to the end of a list you already have.
You simply call [List].append([Float])
, and the job is completed!
Below is a sample of how to use the .append()
method:
lstNumber = [2.0, 1, 3.8, 7, 6.5, 9.2] print(f"The original list: {lstNumber}") # Adds the float "5.6" to the end of the list "lst" lstNumber.append(5.6) print(f"The list after change: {lstNumber}")
The output will be:
The original list: [2.0, 1, 3.8, 7, 6.5, 9.2]
The list after change: [2.0, 1, 3.8, 7, 6.5, 9.2, 5.6]
Using .insert()
The method .insert()
is more flexible. You can take advantage of it to add a float into a specific index position of the list that you desire. There are 2 parameters you need to fill in the method.
You will need to call [List].insert([Index],[Float])
to complete the operation. Don’t forget that the first element in the Python list has the index 0!
Here is the sample using .insert()
method:
lstNumber = [2.0, 3.8, 3, 6.5, 4, 9.2] print(f"The original list: {lstNumber}") # Adds the float "3.2" to the index 2 in the list "lst" lstNumber.insert(2, 3.2) print(f"The list after change: {lstNumber}")
The output will be:
The original list: [2.0, 3.8, 3, 6.5, 4, 9.2]
The list after change: [2.0, 3.8, 3.2, 3, 6.5, 4, 9.2]
Using .extend()
The .extend()
method shows the advantage of adding multiple floats to a list. It will add an iterable of values to the end of the existing list. This feature makes the .extend()
method ideal for combining 2 lists.
To use the method, you will need to call [List].extend([Another List])
.
Below is a sample of adding floats to a list in Python using .extend()
:
lstNumber = [2.0, 1, 3.8, 9, 6.5, 9.2] print(f"The original list: {lstNumber}") # Add the floats "1.0", "3.7", "11.6" in the list "lst" lstNumber.extend([1.0, 3.7, 11.6]) print(f"The list after change: {lstNumber}")
The output will be:
The original list: [2.0, 1, 3.8, 9, 6.5, 9.2]
The list after change: [2.0, 1, 3.8, 9, 6.5, 9.2, 1.0, 3.7, 11.6]
Summary
Above are the top 3 ways to add a float to a list in Python. Among them, I choose the .extend()
method as the best one, as it can help you add many floats to your existing list. Anyway, all are good to use! These methods will give you highly convenience in programming with the Python language!

I am William Nguyen and currently work as a software developer. I am highly interested in programming, especially in Python, C++, Html, Css, and Javascript. I’ve worked on numerous software development projects throughout the years. I am eager to share my knowledge with others that enjoy programming!