Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the homogeneous list in Python list?
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]
Advertisements