Warning – variable referenced before assignment

Having the following snippet: I get a Pycharm warning Local variable cache_data might be used before assignment. Could you please explain how this could possibly happen in this case or is this an inspection bug? Answer Unfortunately this seems to be a known issue in PyCharm that was reported back in Nov 2019. It seems the inspection code added to handle assignment expressions doesn’t recognise that the code inside this conditional can only be reached after setting the local variable. The report notes that it also occurs in comprehension conditionals, and there doesn’t seem to be any fix currently available

How to convert the string to a list of dictionary objects containing two keys with respective values?

I have an external file, and I have to convert the strings from the external file to a list of dictionary objects, containing keys and with respective values. The problem is I keep getting error on the code I already tried, such as “too many values to unpack”. I am really stuck in here. Here is the code: The content of the input.txt looks like this: Answer You need to split by , comma. Also you need a dictionary Use: Output: