0

Hi this is my code i want it to return 'A' but it keeps printing none. I don't know what is the error. Thanks for helping.

def example(inputClass):
    try:
        obj = inputClass()
        obj.errCheck()
    except ValueError as e:
        return e


def example2():
    class test(): 
        def __init__(self):
            pass
        def errCheck(test):
            raise ValueError('A')
    example(test)


def main():
    print(example2())

if __name__ == '__main__':
    main()
1
  • example2() has no explicit return so it returns None Commented Nov 12, 2020 at 5:33

1 Answer 1

2

You need to return the value of example(test) to the caller.

def example2():
    class test(): 
        def __init__(self):
            pass
        def errCheck(test):
            raise ValueError('A')
    return example(test) # this line
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.