How to make an if condition inside a for loop?

Here you go: