You need to create an instance of the
validity
class, and use that instance to call the function. Something like:
v = validity()
while True:
s = input("Enter parentheses : ")
print(s, "-", "is Valid"
if v.f(s) else "is Invalid")
See
9. Classes — Python 3.7.9 documentation[
^].