I have a question on how to automatically generate user names from the user's real name, so that the result is a reference to the real name.
Knowing that the method should be called by telling the person full name and the minimum character limit that this username will have, in addition to verifying that this name already exists and modifying it so there is no conflict, how would this operation be done?
nomes_de_usuarios_atuais = ['ACBETR', 'ZRPACA', 'TRDPOR', 'TRDPOR1']
def gerar_nome_de_usuario(nome, min_caracteres=6):
# ...
nomes_de_usuarios_atuais.append(nome_de_usuario)
print nome_de_usuario
self.assertEqual(gerar_nome_de_usuario('Luis Inacio Lula Da Silva', 6), 'LILDSI')
self.assertEqual(gerar_nome_de_usuario('Ricardo Magalhães', 6), 'RMAGAL')
self.assertEqual(gerar_nome_de_usuario('Ana Carolina Viana', 6), 'ACVIAN')
self.assertEqual(gerar_nome_de_usuario('David Rio', 6), 'DRIO01')
self.assertEqual(gerar_nome_de_usuario('Luis Inacio Lula Da Silva', 6), 'LILDSI1')
In case the return must be the initials of the full name. If the full name has a few words, the algorithm should get more letters (eg: 'Luis Inacio' would be 'LUIINA' ) should complete, and if it still does not result in a minimum of 6 characters, add numbers to the end. If the end result conflicts with already registered user names, the algorithm should add a number to the end.