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

Popular posts from this blog

How to check data type in C++? -

javascript - Is getTimezoneOffset() stable during daylight saving transition? -

sql server - SQL Query returns one result, does not return 0 or NULL result -