How to print items of class including os('clear')?

Refresh

April 2019

Views

16 time

-1

Can somebody explain to me why the menu() function in the code below does not print the attributes of the class person while menu2() does?

Thank you

import os
class person():
    def __init__(self, name, age):
        self.name = name
        self.age = age

    def printAttr(self):
        print([self.name, self.age])


def menu(title = None):
    while True:
        os.system('clear')
        print("A")
        title
        break

def menu2(title = None):
    while True:
        print("A")
        title
        break

Person = person("Peter", 35)
menu(title=Person.printAttr())
print("")
menu2(title=Person.printAttr())

0 answers