“add to set” returns a boolean in java - what about python?

pretke

New Member
In Java I like to use the Boolean value returned by an "add to the set" operation to test whether the element was already present in the set://prints something only if x was not yet included in the set\[code\]if (set.add("x")){print something}\[/code\]My question is, is there something as convenient in Python? I tried\[code\] z = set() if (z.add(y)): print something\[/code\]But it does not print anything. Am I missing something? Thx!
 
Top