03-Adding_Values_to_Dictionary.py


Sign up Free. Don't forget to check out our challenges, lessons, solve and learn series and more ...


Code Snippet

def main():
    #create a dictionary to store teachers and the subject they teach
    teacher_details={"Name": "Mr Moose","Subject": "Philosophy","Hobby":"Chess","School House":"Red House"}
    print(teacher_details)
    print()
    print("...and after adding another key and value..................")
    teacher_details["Salary"]="50K"
    print(teacher_details)
          
main()
                    

Try it yourself