-1

Trying to sum to sets from 2 different txt files with very similar content.

examplet of content:

 https://articulo.mercadolibre.com.ar/MLA-1113638999-placa-de-video-colorful-gt710-nf-1gb-ddr3-garantia-oficial-_JM;Placa De Video Colorful Gt710 Nf 1gb Ddr3 Garantia Oficial;gold_special;True;6999
https://articulo.mercadolibre.com.ar/MLA-795327882-placa-de-video-geforce-gt-710-1gb-ddr3-pc-gamer-gt710-dx12-_JM;Placa De Video Geforce Gt 710 1gb Ddr3 Pc Gamer Gt710 Dx12;gold_special;True;7499

I'm trying to do that with the following code (simplifaction of the original):

with open("gt-710.txt","r") as f:
    a = f.readlines()

with open("gt-7102.txt","r") as f:
    b = f.readlines()


c = set(a).update(set(b))

print(c)

The output i'm getting constantly is NONE, I tried printing each set without updating and they do so properly, but once I try to sume them up they return NONE.

  • I believe this is a duplicate question: https://stackoverflow.com/questions/18038003/python-setdefaultkey-set-update-returns-none – nathan liang Feb 20 '22 at 23:53

1 Answers1

0

update method of set returns None. So what you can do is use a instead of the output of that line;

a = set(a)
a.update(set(b))

Or better yet I would do

c = set(a) | set(b)
  • In [How to Answer](https://stackoverflow.com/help/how-to-answer), note the section _Answer Well-Asked Questions_, and therein the bullet point regarding questions that "have been asked and answered many times before". – Charles Duffy Feb 20 '22 at 23:56