# Why is looping better that if? (L2-DS course)

Hi, everyone!

I’m currently working on L2-DS Knime course and I’m having difficulties understanding the concept of looping.

The task in the first part is “How many days could you stay at maximum for \$150?” and it is solved through looping instead of writting if statement.

Why would I solve it as it is proposed and not in my way through using Column Expression Node. Is it less burden for computer to do so?

05 Loops - Solution.knwf (65.7 KB)

Using CE Node I also get a better result - meaning when the price is 10\$ per night, I get a result of 15 stays, where the iteration column gives 14 (first one is not counted I suppose) for my total budget of 150\$.

Kind regards

Hi there,

I would never argue that something is a better solution. One of my favorite things in KNIME is that nearly every problem has multiple solutions. I would have taken a Moving Aggregation and a Math Formula

Our exercises are designed to exercise a certain topic, in this case it exercises looping.

5 Likes

And to add to what @Iris said: