1
class School:
    school_name='gtti'
    def __init__(self,name,marks):
        self.name=name
        self.marks=marks
    def get_name(self):
        return self.name
    @classmethod
    def get_school(cls):
        return cls.school_name
    @staticmethod
    def number_print(number):
        print("the number is ",number)
print(School.get_school())
print(School.number_print(6))

The output printing as ' gtti the number is 6 None

Why there is extra None is printing in jupyter notebook

MisterMiyagi
  • 44,374
  • 10
  • 104
  • 119
Visakh Vr
  • 11
  • 1

1 Answers1

1

This will work fine, its because you printed out the function call too, which does not return anything

class School:
    school_name='gtti'
    def __init__(self,name,marks):
       self.name=name
       self.marks=marks
    def get_name(self):
       return self.name
    @classmethod
    def get_school(cls):
       return cls.school_name
    @staticmethod
    def number_print(number):
       print("the number is ",number)
                
print(School.get_school())
School.number_print(6)
Master Irfan Elahee
  • 165
  • 1
  • 1
  • 14