(Jun-20-2017, 09:49 AM)bencouve Wrote: Perfect! Thanks ...
and ok
first post
Please don't do this. You're using the wrong data structure. Maybe you want to have a dict:
data = {'i0': 'This', 'i1': 'is', 'i2': 'the', 'i3': 'string'} # direct access print(data['i0']) # iterating over values # unordered for value in data.values(): print(value) # sorted access # sorted sorts by first element, if the the yielded element is a list/tuple for key, value in sorted(data.items()): print(value) # or preserve the order: from collections import OrderedDict data = [('i0', 'This'), ('i1', 'is'), ('i2', 'the'), ('i3', 'string')] ordered_dict = OrderedDict(data) for value in ordered_dict.values(): print(value)Since Python 3.6 dicts preserve the order, but we should not rely on it. Maybe with next version they guarantee it.
Currently it's just an implementation detail.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!