I have a list of dictionaries
list1 = [{'time': '2020', 'name': 'one', 'address': '15423'},{'time': '2021', 'name': 'two', 'address': '8548305'}, {'time': '2019', 'name': 'five', 'address': '15423'}]
I want to convert anything that has address with 15423 to 'Valid' and all the other cases Invalid Final output
list1 = [{'time': '2020', 'name': 'one', 'address': 'Valid'},{'time': '2021', 'name': 'two', 'address': 'Invalid'}, {'time': '2019', 'name': 'five', 'address': 'Valid'}]
Here is what I tried
if '15423' in list1['address']:
list1['address'] = 'Valid'
else:
list1['address'] = 'Invalid'
But I am not sure why it is not working. Maybe I need to loop through the whole column. Appreciate your help