-2
   data = []
    urls = 'onestopfoodandwine.com'
    try:
       urls = f'http://{urls}'
       r = requests.get(url, timeout=4)
    except:
       print('Failed')

    try:
       main_text = r.text
       email = re.findall(r'[\w\.-]+@[\w\.-]+', main_text)
       d = {'urls': url,'emails': email}
       print(d)
       print('--------')
       data.append(d)
       print(data)
    except:
       print('Email doesnt found!')

I have list with dict wich came from websites, it's contains all unique phrase with @, but it's bring also duplicates, wich I need to remove : [{'urls': 'http://onestopfoodandwine.com', 'emails': ['info@onestopfoodandwine.com', 'info@onestopfoodandwine.com', 'info@onestopfoodandwine.com', 'info@onestopfoodandwine.com', 'info@onestopfoodandwine.com', 'info@onestopfoodandwine.com']}] and I want to remove all duplicates from "email" key:

  result = {}

    for key,value in d.items():
        if value not in result.values():
           result[key] = value

    print(result)
Frogleim1
  • 33
  • 2
  • 1
    Didn't you get any results by googling your title?? There are already tons of duplicates on SO! – Thierry Lathuille May 18 '22 at 06:36
  • Yes, I did. but it's not help me. I have try to use many of them , but it's not deleting – Frogleim1 May 18 '22 at 06:44
  • You didn't provide any attempt you made, so we can't know what your exact problem is. Provide a [mre] with well chosen input data, which makes clear what "it doesn't delete" means. All of the answers to the duplicate question give you lists without duplicates. – Thierry Lathuille May 18 '22 at 06:48

0 Answers0