How can we know type of element in Python!

Python has a built-in function called type() that helps you find the class type of the variable given as input. Now we will define the two variables and will print the variables to see the class of variables.

Code:

list1=[“Apple”,”Banana”,”Carrot”,”Dog”,”Engine”]

print(type(list1))

t=tuple([1,2,3,4,5,2,3])

print(type(t))

Output:

<class 'list'>
<class 'tuple'>

Like  "list1" variable is belong to the list class and "t" variable is belong to the tuple class.

Now you can use different classes, try to get the output of class and then validate the class  ? ? .   

 

SHELL SCRIPT TO TAKE BACKUP OF APPLICATION

Leave a Reply

Your email address will not be published. Required fields are marked *