First of all, you have to create a variable to count the number of complaints.
The approach is to go through each Dict
of the List
by using the for loop
. Each Dict
has the <key>
labeled as "Company", while the <value>
of that <key>
is the actual name of the company.
Like in the PDF:
complaintDict: = {...
...
'Company': '<name of the company>'
...}
Therefore, during the loop, you want to check if the company name the user inputted matches with the <value>
of the 'Company'
key of each Dict
. It will be easier if you set another variable to store that <value>
in order to compare it with the user's input.
Every time we go through each Dict
and there is a match, then the count variable will add 1 to itself.
In the end, if that variable equal to 0, the company is definitely not on that list. Otherwise, you can print it.