Having trouble on solving the following tasks

I think i pointed out that i've removed the for loop in replacement for adding and if statement based on the range between values.

I'm sorry, I wrote that comment before seeing your last code.