Different Data Types in Single Program in Python List

Different Data Types in Single Program in Python List. This program can print a different set of data types. In this program, we can use different set programs in a single data type in python programming language.

Different kinds can be found in a Python list! Within a single list, you may store a number, a text, and even another list. The slicing operator may also be used to access a range of items in a list.

Different Data Types in Multiple List

Because it is the base of all classes, you may use it to store any sort of value, such as int, float, String, class objects, or any other java objects. For example, consider the main function code, which generates a new person object with int, float, and string types, then adds it to the List and iterates it using the for loop.

There are no inherent issues with a list containing various data types. Of course, if you try to use that list for something that needs all of the items to be of the same kind, you’ll run into issues. If this is all you’re doing with it, there’s no way it can become an issue in your case.

List in Python Programming

The list is a very flexible Python datatype that can be written as a list of comma-separated values items enclosed in square brackets. The most important aspect of a list is that its items do not have to be of the same type. 

The slice on the left-hand side of the assignment operator can be used to update single or multiple elements of a list, and the append() method can be used to add to elements in a list. To get values from a list, use square brackets for slicing and the index or indices to get the value available at that index.

list1 = ["welcome", "to", "inlarn"]
list2 = [5, 50, 500,5000,50000]


[‘welcome’, ‘to’, ‘inlarn’]     
[5, 50, 500, 5000, 50000]