0
Make a function that given as input a list with contact information and a string, if the string is in the list, must return contact information or contacts.
- Inside the entry list, you have lists with contact information (name, phone(s), email and Instagram).
- the output should be a list of the contact(s) information(s)
- String can be uppercase and lowercase
example:
entrada([[’Juan Silva’,[’2199112233’, ’2133992211’],
’[email protected]’, ’@juansilva91’],
[’maria Leticia’,[’2198145233’], ”, ’@maria.leticia’],
['Daniela Silva',['23456677'],
'[email protected]','@danisilva']],'silv')
As the input string is 'Silv', the output should return the information of the contacts that has Silv in the name (as if it were a search in the mobile agenda)
saida[[’Juan Silva’,[’2199112233’, ’2133992211’],
’[email protected]’, ’@juansilva91’],
['Daniela Silva',['23456677'],
'[email protected]','@danisilva']]
I’m trying with this code but it’s returning an error
def teste(lista_contatos,string):
soma=0
for c in lista_contatos[0]:
if string in lista_contatos[0]:
soma=soma+lista_contatos[0]
return soma
If the output should be a list, because it has
soma = 0
and at the end you return the sum?– hkotsubo
Another detail is that maybe using lists is not the best way to organize the data. Probably a dictionary or a named tuple be more appropriate
– hkotsubo