+ 1
Able to give an element present in a list a certain string index
Well, this is probably a dumb question, or I worded it wrong, but it doesn't hurt to ask. So, recently I started to get into Python more after learning JS, then working with Node.js, but in JS you could give an elements index a specific value (arr["Tile1"] = arr[1]). Is there a way to implement this in python or is it just simply not possible?
2 Réponses
+ 3
In Python, the separation between lists (about JS-Array) and dictionaries (bit more like JS-Object) is strict.
So you have to decide if you want an ordered container with index access (list) or an unordered container with hash access (dict).
Or you define a new datatype of your own.
That's at least what I see. But I remember that Mert Yazıcı often comes up with tricky stuff. :)