I have two lists:
list_a = [["the", "ball", "is", "red", "and", "the", "car", "is", "red"],
["the", "boy", "is", "tall", "and", "the", "man", "is", "tall"]]
list_b = [["the", 0], ["ball", 0], ["is", 0], ["red", 0], ["and", 0], ["car", 0]],
["The", 0], ["boy", 0], ["is", 0], ["and", 0], ["man", 0], ["tall", 0]]
Goals:
Iterate over list_b
, pick up the specific string
and check if it is in list_a
and if so, increase the specific int
by 1.
Important in that context is that I will only compare list_a[0]
with list_b[0]
and list_a[1]
with list_b[1]
.
When finished it should look like that:
list_a = [["the", "ball", "is", "red", "and", "the", "car", "is", "red"],
["the", "boy", "is", "tall", "and", "the", "man", "is", "tall"]]
list_b = [["the", 2], ["ball", 1], ["is", 2], ["red", 2], ["and", 1], ["car", 1]],
["the", 2], ["boy", 1], ["is", 2], ["and", 1], ["man", 1], ["tall", 2]]
for loops
give me massive problems and it seems that this approach is wrong and not suitable for this task, so I am open and thankful for different solutions.