dict data structure

Run Settings
LanguagePython
Language Version
Run Command
# In dictionaries there is a rule - The key needs to be immutable - It cannot be tinkered in any way. # We use strings most common as keys because they are immutable and connot be changed. # we can also use other datatypes instead of a string but if we use a list as a key we get a error in return. dictionary = { 'a': [1,2,3], 'b':'hello', 'x':True } print(dictionary) my_list = [ { 'a': [1,2,3], 'b':'hello', 'x':True }, { 'a': [4,5,6], 'b':'Goodbye', 'x':False } ] print(my_list) print(my_list[0]['a'][2]) print(dictionary['a'][1]) # A key in a dict has to be unique as it represents a bookshelf in that memory space. # When we give the same value again we overwrite it with the new dict key in that memory space. dictionary = { '123':123, '123':'hello'} print(dictionary['123']) # we get hello in the output
Editor Settings
Theme
Key bindings
Full width
Lines