TsTeaTime TsTeaTime - 3 months ago 12
Python Question

How to select Python Tuple/Dictionary Values where Index > x

How do you select python Tuple/Dictionary values where the index is greater than some number. I would think the code should look similar to the following assuming we create a Tuple:

dt = (100, 200, 300,400)
dt[dt.index > 1]

Answer

You could just slice the tuple.

>>> dt = (100, 200, 300,400)
>>> dt[1:]
(200, 300, 400)
Comments