1
I need a code that receives data (values) and prints them according to your key. Each entry corresponds to a given of a hypothetical person, which contains Age, Name, Sex, Marital Status, Number of friends and Number of Photos. I am writing using a dictionary that receives the entries as values and relates them to the keys. How do I do this using Tuples and so that the data is printed in the order it was provided by the user? How am I doing:
Dados = dict()
entrada1 = raw_input()
entrada2 = raw_input()
entrada3 = raw_input()
entrada4 = raw_input()
entrada5 = raw_input()
entrada6 = raw_input()
Dados['Idade'] = entrada1
Dados['Nome'] = entrada2
Dados['Sexo'] = entrada3
Dados['Estado'] = entrada4
Dados['Amigos'] = entrada5
Dados['Fotos'] = entrada6
for chave, valor in Dados.items():
print chave, valor
Also, the code is not printing the keys and values so that a data appears per line, but printing the entire dictionary.
My problem is that the user is the one who determines the order of the data. If he wants to start with Name, then Age, then Friends, anyway. I need to write the code in a way every data provided is "automatically" related to its type. If you enter a name, your key should be Name. If you enter M, your key should be Gender. S - Marital status (single), and so on. I cannot determine that the first input is used as Name, for example. This is my lock.
– Guilherme Santana De Souza