Dictionary in Python

0


Dictionary is used to contain data using key=>value pair .Key is used to provide unique identity and value is used to provide storage.

dictionary always will be declared by { }

student = {'rno':1001,'sname':'manish kumar','branch':'cs'}

here rno, same and branch is the key of a dictionary object.

the dictionary is immutable object means we can change the value of dictionary using the key.


student = {'rno':1001,'sname':'manish kumar','branch':'cs','fees':15000}
for k in student:
    print("key is "+k+" value is "+str(student[k]))

student['sname']='ravi'
#del student['sname']
#print(student['sname'])

student.update({'sem':'5th'})

print(student)











Post a Comment

0Comments

POST Answer of Questions and ASK to Doubt

Post a Comment (0)