Ubah Set Item Python

new_tags = []
for t in tags:
    existing_tag = self.through.tag_model().objects.get(name__iexact=t)
    if existing_tag:
        new_tags.append(existing_tag)
    else:
        new_tags.append(t)
tags = set(new_tags)
Patrick Star