Theory on Dictionary
# Introduction It is an unordered collection of items where each item consists of a key and a value. It is mutable (can modify its contents) but Key must be unique and immutable. Creating Dictionary It is enclosed in curly braces { } and each item is separated from other item by a comma (,).Within each item, key and value are separated by a colon(:). dictonary_name={key:value, key: value, ……..keyN:valueN} Example : day= {1: 'Monday', 2:'Tuesday', 3: 'Wednesday'} print day Output: {1: 'Monday', 2: 'Tuesday', 3: 'Wednesday'} # Accessing Dictionary Item day= {1: 'Monday', 2:'Tuesday', 3: 'Wednesday'} print day print day[1] print day[3] Output: {1: 'Monday', 2: 'Tuesday', 3: 'Wednesday'} Monday Wednesday In above code we are accessing dictionary using key. day= {1: 'Monday', 2:'Tuesday', 3: 'Wednesday'} print(day.get(1)) Output : Monday # Iterating Through A ...