Python

Constant dripping wears away a stone

Nested Structures


Nested Structures: A nested structure is a structure inside another structure.

  • Nested Structure Examples:
    • List in List: A list appears in another list. To access to the content of the nested list, use the index of the corresponding item in the outside list to get to the nested list first, and then use a list item accessing method to access to the content of the nested list.
    • List in Tuple: A list appears in a tuple. To access to the content of the nested list, use the index for the corresponding tuple item to get to the nested list first, and then use a list item accessing method to get the list content.
    • List in Dictionary: A list appears in a dictionary. To access to the content of the nested list, use the key of the corresponding dictionary item to get to the nested list first, and then use a list item accessing method to get the list content.
    • Dictionary in List: A dictionary appears in a list. To access to the content of the nested dictionary, use the index for the corresponding list item to get to the nested dictionary first, and then use a dictionary item accessing method to get the content of the nested dictionary.
    • Dictionary in Tuple: A dictionary appears in a tuple. To access to the content of the nested dictionary, use the index for the corresponding tuple item to get to the nested dictionary first, and then use a dictionary item accessing method to get the content of the nested dictionary.
    • Dictionary in Dictionary: A dictionary appears in another dictionary. To access to the content of the nested dictionary, use the key of the corresponding item in the outside dictionary to get to the nested dictionary first, and then use a dictionary item accessing method to get the content of the nested dictionary.
    • Tuple in List: A tuple appears in a list. To access to the content of the nested tuple, use the index for the corresponding list item to get to the tuple first, and then use a tuple item accessing method to get the content of the nested tuple.
    • Tuple in Tuple: A tuple appears in another tuple. To access to the content of the nested tuple, use the index for the corresponding item in the outside tuple to get to the nested tuple first, and then use a tuple item accessing method to get the content of the nested tuple.
    • Tuple in Dictionary: A tuple appears in a dictionary. To access to the content of the nested tuple, use the key of the corresponding item in the outside dictionary to get to the tuple first, and then use a tuple item accessing method to get the content of the nested tuple.
    • Tuple in Set: A tuple appears in a set. To access to the content of the nested tuple, use a set item accessing method to get to the tuple first, and then use a tuple item accessing method to get the content of the nested tuple.
    • Set in List: A set appears in a list. To access to the content of the nested set, use the index for the corresponding list item to get to the set first, and then use a set item accessing method to get the content of the nested set.
    • Set in Tuple: A set appears in another tuple. To access to the content of the nested set, use the index for the corresponding tuple item to get to the nested set first, and then use a set item accessing method to get the content of the nested set.
    • Set in Dictionary: A set appears in a dictionary. To access to the content of the nested set, use the key of the corresponding item in the outside dictionary to get to the set first, and then use a set item accessing method to get the content of the nested set.