You can loop through lists and dictionaries using the for keyword. For example, do this to go through a list:
for animal in animals echo animalendfor
And here's you iterating through a dictionary:
for animal in keys(animal_names) echo 'This ' . animal . '''s name is ' . animal_names[animal]endfor
You can also access both the key and the value of the dictionary simultaneously using items:
for [animal, name] in items(animal_names) echo 'This ' . animal . '''s name is ' . nameendfor
You can control the iteration flow with continue and break. Here's an example of using break:
let animals = ['dog', 'cat', 'parrot']for animal in animals if animal == 'cat' echo 'It''s a cat! Breaking!' break endif echo 'Looking at a ' . animal . ', it''s ...