class human(object):
kind = 'humam'
def __init__(self,name, sex, age):
self.name = name
self.sex = sex
self.age = age
def report(self):
print(self.name)
print(self.sex)
print(self.age)
com = int(input('What would you like to do: \n 1) Add a contact \n 2) Info on a contact \n 3) Break\n'))
while com != 3:
if com == 1:
name,sex,age = input('Enter name sex age: ').split()
name = human(name,sex,age)
if com == 2:
name = input('Enter name: ')
name.report()
com = int(input('What would you like to do: \n 1) Add a contact \n 2) Info on a contact \n 3) Break\n'))
After defining some objects of human, I could not access them if it was not during the same execution, for example, selecting 1 to add contact, once instantiated john = human ('john', 'male', '20' ) When you select 2 to check the object information the following error appears: name.report () AttributeError: 'str' object has no attribute 'report' How can I resolve this?