About dict.items() method...`

if we have a dictionary named a
suppose a is like this:-
a = {

"name" : "Bihan",
"marks" : 99,
"sunjects" : ["Eng", "Math"],
"friends" : {
    
    "Sourav" : "Android",
    "Sachin" : "IOS"
    
}

}
Now if I do a.items() I will get each key-value pair in a tuple… a tuple for each key-value pair. but as a.keys() is iterable then I just want to know whats the data type of b is, where b = a.items() … Where does the Each of the tuples containing a key-value pair reside? Are they inside a list or all the tuples are inside a tuple???
If i do :- type(b) then its showing :-
dict_items([(‘name’, ‘Bihan’), (‘marks’, 99), (‘sunjects’, [‘Eng’, ‘Math’]), (‘friends’, {‘Sourav’: ‘Android’, ‘Sachin’: ‘IOS’})])…
What should I assume ?? is it b is a tuple containing a list which contains all the tuples ??? or something else???

hey buddy ,
dict_items is a separate class which is a inherited from List .
this is the reason you see that on type(b

you don’t have to assume , why do you want to assume something ?

a list of tuples

1 Like

That’s what exactly I wanted to know… Thanx…
dict_items([(‘name’, ‘Bihan’), (‘marks’, 99), (‘sunjects’, [‘Eng’, ‘Math’]), (‘friends’, {‘Sourav’: ‘Android’, ‘Sachin’: ‘IOS’})])…
I actually got confused with the first bracket () given after dict_items…

Yeah that confuses sometimes, no issues.

1 Like

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.