EPI Python 16.7 Missing continue in the for loop for bedbathbeyond problem

#1

I was expecting the code to have a “continue” statement after the if statement in the code below,

...
# If domain[:i + 1] is a dictionary word, set last_length[i] to the
        # length of that word.
        if domain[:i + 1] in dictionary:
            last_length[i] = i + 1
            continue // Here.
...

I agree that this might seem extraneous to a lot of people given that the code that follows does not have a side-effect due to a guarding condition, but it affected my reading of this code because I was expecting the loop to continue with the next iteration rather than moving forward in the current iteration (where there is nothing left to do).

Is my understanding correct?

0 Likes

#2

Hi @interviewing.joe,

I think it is definitely good to add a continue here as the following block won’t execute if this passed. I have updated the solutions here, and will add that in the next release of judge.

0 Likes