I have written a piece of code which takes a keyword and splits a name using that specific keyword, however as split returns the list, now I want to individually check the elements of the returned list and again split it using a different keyword(if it exists), but this time I dont want another sublist to be returned, rather then the elements should get extended in the same list.
Code below :-
def get_comb_drugs(keyword, name):
if keyword in name:
name = name.split(keyword)
return name
print(get_comb_drugs(", polymer with", "Acetaldehyde, polymer with ammonia and formaldehyde"))
The output I get is:
['Acetaldehyde', ' ammonia and formaldehyde']
however, I want to split 'ammonia and formaldehyde' again using " and " keyword and the exact output I want is:
['Acetaldehyde', ' ammonia', 'formaldehyde']
Guide me in achieving the desired result.