Python Array with string AND integer indices -
i'm trying create array uses strings , integers indices.
ademo[int]["string"] = "test"
is possible , if yes how declared?
a data structure can indexed keys (like strings, or else) called associative array. built-in python implementation of called dict
(dictionary). can create dict
using curly braces syntax:
ademo = [] = { "apple": "red", "banana": "yellow", "cucumber": "green" } ademo.append(a) print ademo[0]["apple"] # "red"
a dict
has plenty of other methods , ways modified , created, check official documentation.
Comments
Post a Comment