I'm just starting out at Python and need some help with dictionaries. I'm looking to add keys to a dictionary based on input that is a list with string elements:
Ex.
x = {}
a = ['1', 'line', '56_09', '..xxx..']
Now say a while loop has come to this list a. I try to add to the dictionary with this code:
if a[1] == 'line':
x[a[2]] = [a[-1]]
I want the dictionary to read x = { '56_09': '..xxx..'}
and want to confirm that by printing it. Do i need to adjust the elements on the list to strings or is it something with the if statement that I need to change?