Artery
0
Q:

how to print a value from a dictionary in python

#print keys and values from the dictionary

for k, v in dic.items():
  print(k, v)
4
dictionary={
  
    "Jeff":{
      	"lastname":"bobson",
        "age":55,
        "working":True
    },
  
    "James":{
      	"lastname":"Bobson",
        "age":34,
        "working":False
    }
}

for i in dictionary:
    print(i,":")
    for j in dictionary[i]:
        print("  ",j,":",dictionary[i][j])
    print()
        

# output:

Jeff :
   lastname : bobson
   age : 55
   working : True
   
James :
   lastname : Bobson
   age : 34
   working : False
2

New to Communities?

Join the community