-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
  • 55,782
  • 14
  • 81
  • 108

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,295
  • 1
  • 8
  • 25