0
class company:

    def __init__(self,name,lname):
        self.name = name
        self.lname = lname


    def fullname(self):
        print(f'{self.name} {self.lname}')

    def display(self):
        print(f'{self.fullname()}')

emp1 = company('john','king')
emp1.display()

output is

john king
None
Barmar
  • 741,623
  • 53
  • 500
  • 612

1 Answers1

2

This is because the method fullname is not returning anything (None). To use the function like you expected, instead of printing the string, return it.

def fullname(self):
    return f'{self.name} {self.lname}'
HerrAlvé
  • 587
  • 3
  • 17