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

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -