Dec-12-2018, 03:04 AM
(This post was last modified: Dec-12-2018, 03:04 AM by beepBoop123.)
Hi, I currently need some help getting the index to show with the words I split and and made uppercase. This may me an easy fix or more complicated, I just don't understand what to do now. If anyone knows how to do this or has suggestions to guide me in the right path that would be greatly appreciated. Commented out is what the output should look like.
['FOUR', 'SCORE', 'AND', 'SEVEN', 'YEARS', 'AGO', 'OUR', 'FATHERS', 'BROUGHT', 'FORTH', 'ON', 'THIS', 'CONTINENT,', 'A', 'NEW', 'NATION,', 'CONCEIVED', ..]
def get_inverted_index(text): newText = text.upper().split(" ") return newText
gettysburg_address = "Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the ..." print(get_inverted_index(gettysburg_address)) # Output starts: # {'FOUR': [0], 'SCORE': [1], 'AND': [2, 19, 48, 95,...This is what I have so far:
['FOUR', 'SCORE', 'AND', 'SEVEN', 'YEARS', 'AGO', 'OUR', 'FATHERS', 'BROUGHT', 'FORTH', 'ON', 'THIS', 'CONTINENT,', 'A', 'NEW', 'NATION,', 'CONCEIVED', ..]