I realize how poorly worded the title is, but I am beyond lost as to what the actual problem is to begin with as I'm not getting much predictable behavior. So feel free to suggest changes or whatever.
I'm trying to iterate through a list of words followed by identifiers (ie. 'Bus', 'n.', 'C1') and classify the words themselves into one one of several lists of dictionary values based on the identifiers that follow each word.
My problem is that I cannot get Python to finish iterating through the list. Conditions are obviously met and then disregarded.
I've tried using 'elif' (it shouldn't matter if the conditions are exactly met?) and reodering the if/elif statements to no avail. The current script below iterates further than any other configuration I tried.
dict = {'noun':[], 'verb':[], 'adj':[], 'adv':[], 'prep':[]}
oxfi = "adaptation n. C1 addiction n. B2 additionally adv. B2 adequate adj. B2 adequately adv. B2 adhere v. C1 adjacent adj. C1 adjust v. B2 adjustment n. C1 administer v. C1 administrative adj. C1 administrator n. C1 admission n. C1 adolescent n. C1 adoption n. C1 adverse adj. C1 advocate n., v. C1 aesthetic adj. C1 affection n. C1 affordable adj. B2"
oxfi = oxfi.split()
for word in oxfi:
if oxfi[1] == 'n.,' and oxfi[2] == 'v.':
dict['noun'].append(oxfi[0])
dict['verb'].append(oxfi[0])
del oxfi[0:4]
if oxfi[1] == 'n.':
dict['noun'].append(oxfi[0])
del oxfi[0:3]
if oxfi[1] == 'adj.':
dict['adj'].append(oxfi[0])
del oxfi[0:3]
if oxfi[1] == 'v.':
dict['verb'].append(oxfi[0])
del oxfi[0:3]
if oxfi[1] == 'adv.':
dict['adv'].append(oxfi[0])
del oxfi[0:3]
if oxfi[1] == 'prep.':
dict['prep'].append(oxfi[0])
del oxfi[0:3]
print("oxfi = " + str(oxfi) + '\n')
print("dict = " + str(dict) + '\n')
I'm an intermediate Python hobbyist, and will admit this has me totally stumped. Any help is greatly appreciated!!