I have a text file (attachment.txt), which I have to store in a dictionary, with Name as key and phone, value. the file has the following information:
--- nome telefone ---
Ailton-1197765445 Josefa-2178655434
I used the following code:
ref_files = open("anexo.txt", "r")
for linha in ref_files:
valos = linha.split()
print(valos[0],valos[:0],valos[1:])
ref_files.close()
but it returns values like this: Ailton-1197765445 [] ['Josefa-2178655434']
I created the dictionary but the return is the same:
dic = { k.split()[0]:k.split()[1:] for k in ref_files.readlines() }
Could anyone help me with this? Grateful.