0

I called the other function from the first function. when I return the first function, I am getting python None on the screen.

class test():

    def test1(self, userinput):

        return self.test2(userinput)

    def test2(self, urls):

        string = "this is " + urls
        self.test3(string)

    def test3(self, sentence):
        return sentence


if __name__ == "__main__":

    objectt = test()
    seek = "concept of my functions"
    print(objectt.test1(seek))
2
  • 1
    The test2 function doesn't return anything, so it returns None by default Commented Dec 9, 2019 at 7:06
  • Please learn about rubber duck debugging. Attempting to explain the code to a "rubber duck" (or roommate, friend or other suitable substitute) often helps. Commented Dec 9, 2019 at 7:06

1 Answer 1

2

In test2, you call test3.

test3 returns 'this is concept of my function' to test2. Then, test2 returns nothing to test1 - so, as all functions that don't return anything specific, it returns None, which in turn is returned by test1.

You have to return the output of test3 at the end test2: class test():

class test:
    def test1(self, userinput):

        return self.test2(userinput)

    def test2(self, urls):

        string = "this is " + urls
        return self.test3(string)

    def test3(self, sentence):
        return sentence


objectt = test()
seek = "concept of my functions"
print(objectt.test1(seek))

# this is concept of my functions
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.