This is my code:
domains = ['google.com', 'yahoo.co', 'bing.msn', 'biz.info', 'you.biz', 'test.store', 'myblog.blog', 'finally.xyz']extensions = ['.blog', '.co', '.com', '.store', '.xyz']
Finally, I'm going to remove domain names which have the extension in the extensions
list, and keep other domains which do not have those extensions.
Expected output is:
domains = ['bing.msn', 'biz.info', 'you.biz']
I tried this too (former edit3
):
>>> domains[:] = [x for x in domains for e in extensions if not x.endswith(e)]>>> domains['google.com', 'google.com', 'google.com', 'google.com', 'yahoo.co', 'yahoo.co', 'yahoo.co', 'yahoo.co', 'bing.msn', 'bing.msn', 'bing.msn', 'bing.msn', 'bing.msn', 'biz.info', 'biz.info', 'biz.info', 'biz.info', 'biz.info', 'you.biz', 'you.biz', 'you.biz', 'you.biz', 'you.biz', 'test.store', 'test.store', 'test.store', 'test.store', 'myblog.blog', 'myblog.blog', 'myblog.blog', 'myblog.blog', 'finally.xyz', 'finally.xyz', 'finally.xyz', 'finally.xyz']