Beginner here (meaning I probably did something silly):
I am trying to target indexed elements that have [A], in them. Entries for 'scarcity' and 'sweet' are both shown.
I am running into trouble when index item is empty. I get the following message:
['scarcity', 'scarce', '[A],', 'ity', '[N|A]', '[N]'] scarcity scarce [A], ity [N|A] [N] scarcity [A], ['sweet', ','] sweet , Traceback (most recent call last): File "final3.py", line 69, in <module> dict_pos = item IndexError: list index out of range
This is what the code is:
for line in dictionary: line = line.replace('(', ' ').replace(')', ' ') item = line.split() print item print line dict_word = item dict_base = item dict_pos = item print dict_word if not dict_pos: print "[X]," else: print dict_pos
Edited 4 Years Ago by peter_budo: Keep It Clear - Do use code tags when posting any code