You could use a dictionary:
names = ['test','hallo','test']
countnames = {}
for name in names:
countnames[name] = countnames.get(name, 0) + 1
print(countnames) # => {'test': 2, 'hallo': 1}
If you want to make it case-insensitive, use this:
names = ['test','hallo','test', 'HaLLo', 'tESt']
countnames = {}
for name in names:
name = name.lower() # => to make 'test' and 'Test' and 'TeST'...etc the same
countnames[name] = countnames.get(name, 0) + 1
print(countnames) # => {'test': 3, 'hallo': 2}
In case you want the keys to be the counts, use an array to store the names in:
names = ['test','hallo','test','name', 'HaLLo', 'tESt','name', 'Hi', 'hi', 'Name', 'once']
temp = {}
for name in names:
name = name.lower()
temp[name] = temp.get(name, 0) + 1
countnames = {}
for name, count in temp.items():
countnames.setdefault(count, []).append(name)
print(countnames) # => {3: ['test', 'name'], 2: ['hallo', 'hi'], 1: ['once']}