Given 2 lists of same length ,the operation I want to perform is lookup in second list and merge the result in original list. However, the key and value of lookup changes. # Input data = ["A", "ReplaceMe", "ReplaceMe", "A", "ReplaceMe", "C"] replace_values = ["Version1", "", "", "Version2", "", ""] # Expected output [‘A’, ‘Version1’, […]
Categories
Lookup and merge using lists in python
- Post author By Full Stack
- Post date April 10, 2021
- No Comments on Lookup and merge using lists in python
- Tags 'C'] def replace_elements(dataset, "", ""] # Expected output ['A', "C"] replace_values = ["Version1", "ReplaceMe", \"version\":2}", a, but has O(n) complexity. Can I use dict to get this done in a faster way ?, Given 2 lists of same length, i in enumerate(dataset): if i == "A": replace_by = replacements[j] if i == "ReplaceMe": dataset[j] =, replacements): for j, the key and value of lookup changes. # Input data = ["A", the operation I want to perform is lookup in second list and merge the result in original list. However, version=1