+ 1
How to print dictionary like table format?
d={"apple":{"num": 3}, "Orange":{"num": 1}} how to print like this: >>> fruit num apple 3 Orange 1
2 Answers
+ 3
for key, value in d.items():
print(key + "\t" + str (value["num"]))
str.format() would probably be better though.
0
for i in d:
print('\t'+i+'\t\t\t\t'+str(d['num']))