To resolve this issue, just use the following code:
lstNomes = ["casa", "google", "escola"]
lstFiltro = list(filter(lambda x: len(x) <= 5, lstNomes))
print(lstFiltro)
Observation 1:
How you want to capture words of size less than or equal to 5 and, as the elements of the list are strings, you should check the size of each iterated element, then display them.
Observation 2:
In this case it was displayed only 1 result. Because in this case, we only have one word of size less than or equal to 5.
Now, if there were other words in this list of sizes less than or equal to 5, all of them would be shown.
Change made!
– Camilla Marques
Thank you. Good luck!
– Solkarped