Correct Syntax to read Data from an Arrayvariable ?


I’ve something like this:


Which returns me this:

{'de': ['Flugzeug'], 'fr': ['avion'], 'en': ['airplane']}

What I want is to get for example the name for airplane in german.

I tried:


But this returns me an error.

What is the correct Syntax to get the word for airplane in german ?

Kind regards

The type of data structure is called a dictionary in python.
The syntax you use is correct, why the string is in a list I don’t know.
To get more help you need to provide the error message and more of the context.

>>> airplanes
{'fr': ['avion'], 'de': ['Flugzeug'], 'en': ['airplane']}
>>> airplanes['de']

It works now.
I don’t know what my little dumphead has done wrong before.

Thanks anyway.

Kind regards

any reason for using lists of strings instead of plain strings?

Sorry I don’t understand the question, what’s the difference ?

Kind regards

{'de': ['Flugzeug'], 'fr': ['avion'], 'en': ['airplane']}


{'de': 'Flugzeug', 'fr': 'avion', 'en': 'airplane'}

If the dictionary maps language code keys to single translations of a common word, there is really no need to put the translations in lists. It takes more memory and is less efficient if you use lists with a single string inside.