Last answered:

04 Aug 2022

Posted on:

03 Aug 2022

0

Do we need the else statemet if we do not change any variable?

In the solution the else statement does not modify the variable
image.png
is it needed or can we omit it?

1 answers ( 0 marked as helpful)
Instructor
Posted on:

04 Aug 2022

0

Hi Marc!
Thanks for reaching out.

Yes, this exercise could be solved without these two lines of code, that's right. However, best practices require to leave code that is visible for other readers what will happen to the base value in case the if statement has not been satisfied. Hence, the version we've left as a solution to our exercise.

Hope this helps.
Best,
Tsvetelin

Submit an answer