Dec-22-2020, 08:43 PM
Line 4 takes the information on one line of the file and attempts to read it as two pieces of data (a "key" and a "value"). Depending on the format of the file, this might have to be changed to gather the correct information.
Line 5 is one way of populating a dict. It sets the entry for "key" to be "value". You can print out the dictionary afterward and see the information.
Line 5 is one way of populating a dict. It sets the entry for "key" to be "value". You can print out the dictionary afterward and see the information.
>>> dictionary = {} >>> dictionary["key"] = "value" >>> dictionary["A"] = 5 >>> print(dictionary) {'key': 'value', 'A': 5}