If you have a dictionary, you can do something like this:
import re dict = { 'Key_1':[1,2,3], 'Key_2':[4,5,6], 'Key_3':[6,7,8] } r = re.compile(r"Key_\d+") // matching expression matching_keys = filter(r.match, dict.keys())
That way you can get all the relevant keys, and then just iterate over those keys.
source share