I am new to python and wanted to know if there are best approaches for solving this problem. I have a string template which I want to compare with a list of strings and if any difference found, create a dictionary out of it.
template = "Hi {name}, how are you? Are you living in {location} currently? Can you confirm if following data is correct - {list_of_data}"
list_of_strings = [
"Hi John, how are you? Are you living in California currently? Can you confirm if following data is correct - 123, 456, 345",
"Hi Steve, how are you? Are you living in New York currently? Can you confirm if following data is correct - 6542"
]
expected = [
{"name": "John", "location": "California", "list_of_data": [123, 456, 345]},
{"name": "Steve", "location": "New York", "list_of_data": [6542]},
]
I tried many different approaches but ended up stuck in some random logics and the solutions did not look generic enough to support any string with the template. Any help is highly appreciated.