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()
Asked By: Dev_Van

||

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')
Answered By: Jamiu Shaibu
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.