1
Hello, I’m doing the following in python:
I created an array of dictionaries and would like to search within this array if a given word exists.
Ex:
palavra1 = {'palavra': 'sim', 'positivo': 0}
palavra2 = {'palavra': 'não', positivo: 0}
palavras = [palavra1, palavra2]
I would like to search whether the word 'yes' is within 'words'. How do I do that?
I thought about using the words.index() method, but I also need to use the dictionary get method to check the 'word' value, as I would do this?
Don’t you want to search for the key? Want to search for the value? If yes, the idea is this https://answall.com/a/254612/64969, but the implementation would need some adjustments to fit the list of dictionaries
– Jefferson Quesado
I want to search for the value, because the 'word' key will always be the same... What I want to do at the end of the day is to count the number of positives and negatives in a list of repeating words. So what I really want to do is go through that list. If the word exists, account +1 in positive or negative, depending on its classification in another structure..
– Gabriel Augusto