I need to pair the score of a movie review to every single word of the review line. For example, if the review line is "3 I love this movie"
. Then the dictionary should have:
dict = {3:I, 3:love, 3:this, 3:movie}
Here is my code:
#function to pair every single word with the score attributed to the review.
def pair_word_with_score(user_input):
#create a dictionary
pair_dict = {}
words = user_input.split()
for word in words:
pair_dict[words[0]] = word
return pair_dict
def main():
user_input = input("Please enter a review \n")
#call the pairing function
print(pair_word_with_score(user_input))
if __name__ == "__main__":
main()
When I call the function, it only prints {3:movie}
. The other values are overridden.