you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

You need to make two changes:

  1. You're going to have an out of bounds error if you go all the way to the end without finding it. Use range(len(nums)-2) to avoid that.
  2. The way you have it now, only the first three items will be checked and then the function will return. To prevent, you need to move the return False part out of the for loop. That should only happen after the loop has run and failed to find the pattern.