Hi all,
Can you help me with the following double for loop, writing it more cleanly and make it work for 'lc3'
Can you help me with the following double for loop, writing it more cleanly and make it work for 'lc3'
old = 'car' new = 'scooter' loadcases = {'lc1': [['car', 'red', '10'], ['train', 'blue', '20'], ['airplane', 'gray', '300']], 'lc2': [['bike', 'red', '10'], ['train', 'blue', '20'], ['car', 'gray', '300']], 'lc3': 'car'} # this works for lc1 and lc2 but not for lc3, how can I incorporate this too? for lc in loadcases: for element in loadcases[lc]: if element[0] == old: element[0] = newThe output needs to be as follows:
Output:{'lc1': [['scooter', 'red', '10'], ['train', 'blue', '20'], ['airplane', 'gray', '300']], 'lc2': [['bike', 'red', '10'], ['train', 'blue', '20'], ['scooter', 'gray', '300']], 'lc3': 'scooter'}