Data structures generic data type

Hai , I see that the ds in python are generic I.e it can store all data types that’s what I mean here

If I need to store data of a specified data type in python what should be done.

Hi @Ramu-Rebal-2078248865781508

This concept where the data types are of secondary importance is called duck typing. Python being a completely duck-typed language does not has any support for specifying the type of objects/variables (right now). Only thing you can do is check the type of an object before using it through the isinstance method:

if isinstance(my_var, int):
    my_var += 5

Hope this helps!

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.