I have created a List using items() method on a Dictionary variable. But why I am not able to access a particular index of that List
Because you’re trying to index the object that isn’t a list itself.
Try:
List1 = list(List1)
Although you have to keep in mind that the order of keys in dictionary can’t be guaranteed to be the same every time, so the “first” element of person1.items()
might be different every time you run this code.
2 Likes
Thanks Sebastian for pointing this out. Got it !!!