Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Homogeneous List in Python



In Python, a list is a mutable data type used to store a collection of items, which are separated by commas and enclosed within square brackets [ ].

According to the Python documentation, there is no concept of a homogeneous list in Python. However, a Python list can contain collections of homogeneous items, meaning that the data types of the items are the same.

Python List of Homogeneous Data

A Python list can contain both homogeneous and heterogeneous data.

Example 

Here is an example of a list containing homogeneous data -

# List containing string data
l1 = ["Tutorialspoint", "Edtech", "Limited"]
print("List of strings:", l1)

# List containing Integer data
l2 = [1,2,3,4,5]
print("List of strings:", l2)

# List containing floating-point data
l3 = [1.1,2.2,3.3,4.4,5.5]
print("List of strings:", l3)

Following is the output of the above program -

List of strings: ['Tutorialspoint', 'Edtech', 'Limited']
List of strings: [1, 2, 3, 4, 5]
List of strings: [1.1, 2.2, 3.3, 4.4, 5.5]
Updated on: 2025-05-20T14:52:06+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements