-1

I am trying to add a frozenset to an already existing set of frozensets however when i try to use the add() function to add it the return is None. I tried using the update() function instead but to no avail. I am forced to use frozensets because I need a set of sets and this seems like the only solution in Python. The literal is just a list of one element of type String.

    print(literal)
    print(clauses)
    clauses = clauses.add(frozenset(literal))
    print(clauses)

The output looks like this:

['!y']
{frozenset({'!y', 'z', 'x'})}
None
Chops
  • 462
  • 2
  • 7
  • 19

1 Answers1

3

The general rule (https://docs.python.org/3/library/stdtypes.html)

The methods that add, subtract, or rearrange their members in place, and don’t return a specific item, never return the collection instance itself but None.

That's why:

clauses = clauses.add(frozenset(literal))

means:

clauses.add(frozenset(literal))
clauses = None
VPfB
  • 14,927
  • 6
  • 41
  • 75