in python 3.x
you can use:
for k,v in std.items():
print(k,v['Uid'])
in python 2.x
:
for k,v in std.iteritems():
print(k,v['Uid'])
python 3.x
code:
std={}
n=int(input("How many Entries you have to fill:"))
for i in range (n):
name=input("Enter name:")
uid=input("ID:")
age=input("Age:")
print("----Marks----")
math=input("Maths:")
phy=input("Physics:")
chem=input("Chemistry:")
std[name]={'Uid':uid,'Age':age,'subject':{'math':math,'phy':phy,'chem':chem}}
print('\n')
for k,v in std.items():
print(k,v['Uid'])
input and results for 2 different names will be:
How many Entries you have to fill:2
Enter name:John
ID:15895
Age:18
----Marks----
Maths:15
Physics:15
Chemistry:15
Enter name:Beck
ID:52256
Age:54
----Marks----
Maths:52
Physics:52
Chemistry:21
John 15895
Beck 52256
solved print key and only one value from dictionary