+ 1
What's wrong with the code , excepted output is true but it showing false.
def arrayCheck(nums): for i in range(len(nums)-2): if nums[i]==1 and nums[i+1]==2 and nums[i +2]==3: return True return False '''nums=[1,2,3,1] value=arrayCheck(nums) print(value) nums=[1,1,2,4,1] value=arrayCheck(nums) print(value)''' nums=[1,2,1,2,3] value=arrayCheck(nums) print(value)
1 Answer
+ 4
`return False` should be outside of the `for` loop (same indentation level).