I have a dictionary:
dic={\'Tim\':3, \'Kate\':2}
I would like to output it as:
Name Age
Tim 3
Kate 2
Is i
You can do it directly as in
>>> print("Name\tAge")
Name Age
>>> for i in dic:
... print("{}\t{}".format(i,dic[i]))
...
Tim 3
Kate 2
>>>
It displays even better if executed as a script
Name Age
Tim 3
Kate 2
And for the other representation
lst = [{'Name':'Tim', 'Age':3}, {'Name':'Kate', 'Age':2}]
print("Name\tAge")
for i in lst:
print("{}\t{}".format(i['Name'],i['Age']))
And for your final question - Is it a good way to first convert them into a list of dictionaries Answer is No, A dictionary is hashed and provides faster access than lists