AttributeError: 'NoneType' object has no attribute 'title', how can I resolve this error
Question:
I want to add names in capital to group_list from names list but I get AttributeError: ‘NoneType’ what am I doing wrong? and also I want to know how many names are added to group_list. I hope someone can help me out.
group_list = ['Jhon', 'James', 'Rita', 'Ruth']
names = ['issah', 'ruth', 'kane']
for name in names:
if name.title() not in group_list:
group_list.append(name).title()
Answers:
number_of_names_added = 0
group_list = ['Jhon', 'James', 'Rita', 'Ruth']
names = ['issah', 'ruth', 'kane']
for name in names:
if name.title() not in group_list:
group_list.append(name.title()) # Correction here
number_of_names_added += 1
print(f'{number_of_names_added} name(s) added to group_list')
I want to add names in capital to group_list from names list but I get AttributeError: ‘NoneType’ what am I doing wrong? and also I want to know how many names are added to group_list. I hope someone can help me out.
group_list = ['Jhon', 'James', 'Rita', 'Ruth']
names = ['issah', 'ruth', 'kane']
for name in names:
if name.title() not in group_list:
group_list.append(name).title()
number_of_names_added = 0
group_list = ['Jhon', 'James', 'Rita', 'Ruth']
names = ['issah', 'ruth', 'kane']
for name in names:
if name.title() not in group_list:
group_list.append(name.title()) # Correction here
number_of_names_added += 1
print(f'{number_of_names_added} name(s) added to group_list')