-2

For this code:

class Test:
    def __init__(self):
        self.a=10
        self.b=20

    def display(self):
        print(self.a)
        print(self.b)

when I use print(t.display()) it gives me 10,20,None. I don't understand why None is appearing.

khelwood
  • 52,115
  • 13
  • 74
  • 94

1 Answers1

0

Every function returns None by default. If you print a function with no return statement, the function returns None and then prints None.

Banana
  • 2,053
  • 1
  • 7
  • 23