I would do that using a dictionary comprehension within a list comprehension.
The dictionary comprehension rebuilds the dictionary, but alters the value if:
- key is
key3 AND
- first 2 chars of the string are digits
Alteration is taking the right part of the leading space.
a_list = [{'key1': 'A picture 1', 'key2': 'location 1', 'key3': '20 title1'}, {'key1': 'A picture 2', 'key2': 'location 2', 'key3': '10 title2'}]
a_new_list = [{k:v.partition(" ")[2] if (k=="key3" and v[:2].isdigit()) else v for k,v in d.items()} for d in a_list]
print(a_new_list)
result:
[{'key1': 'A picture 1', 'key2': 'location 1', 'key3': 'title1'}, {'key1': 'A picture 2', 'key2': 'location 2', 'key3': 'title2'}]
Note: Will also remove the first digits if there are more than 2 digits. The condition is broad and should be tuned to your needs.
EDIT: a pre Python 2.7 compliant alternative (dict comprehensions when did not exist):
a_new_list = [dict((k,v.partition(" ")[2] if (k=="key3" and v[:2].isdigit()) else v) for k,v in d.items()) for d in a_list]